1
votes

I'm having a bit of trouble updating a PFObject on my iOS app. This was working previously when we were logging in with the logInWithUsername:password: method. We have recently switched to logging the user in with cloud code, returning a session token and using becomeInBackground: method instead. This is much nicer and more secure, but now we have quite a big issue.

I have a class called Merchant, which has a column called "agents", which contains an array of pointers to other PFUsers. A user can administrate a merchant (ACL is all fine - no worries there) and add or remove "agents".

The code to remove an agent is fairly straightforward (merchant is a Merchant object, agent is a PFUser object, and the [PFUser currentUser] is definitely authenticated) -

    [merchant.agents removeObject:agent];
    [merchant saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        completionBlock(succeeded, merchant);
    }];

On saveInBackgroundWithBlock, I get [Error]: Caught "NSInternalInconsistencyException" with reason "User cannot be saved unless they have been authenticated via logIn or signUp"

I'm a bit stumped at the moment and don't really want to go back to the old login method. It's also a bit confusing as I'm not even trying to save a PFUser, but a Merchant object. Any ideas?

1

1 Answers

1
votes

It turns out I was storing a value in the user object and Parse was trying to update my child objects as they were now dirty.