parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Setting custom PFUser properties after SignUp no longer works in 2.6.0/2.6.1

Open oyvindvol opened this issue 9 years ago • 9 comments

Issue Description

After a user signs up in my app I set a few custom properties on the user object in

- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user {
    user[@"appUser"] = @YES;
    user[@"deleted"] = @NO;
    [user save];
    ...

This worked fine up until parse-server 2.5.3, but now the properties are not set, and the log shows:

error: Error generating response. ParseError { code: 206, message: 'Cannot modify user <object id>.' } code=206, message=Cannot modify user <object id>.

error: Cannot modify user <object id>. code=206, message=Cannot modify user <object id>.
heroku[router]: at=info method=PUT path="/parse/classes/_User/<object id>" host=<my host> request_id=<123> fwd="<123>" dyno=web.1 connect=0ms service=58ms status=400 bytes=586 protocol=https

Steps to reproduce

Use parse server 2.6.1, and an ios app with parse user registration. Try to set custom properties on the PFUser object after registration. See in parse database that the properties are not set.

Expected Results

The custom properties are set.

Actual Outcome

The properties are not set, and an error occur in the logs.

Environment Setup

  • Server

    • parse-server version: 2.6.1
    • Operating System: Heroku dynos
    • Hardware: Heroku dynos
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Heroku
  • Database

    • MongoDB version: mLab
    • Storage engine: mLab
    • Hardware: mLab
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

Logs/Trace

error: Error generating response. ParseError { code: 206, message: 'Cannot modify user <object id>.' } code=206, message=Cannot modify user <object id>.

error: Cannot modify user <object id>. code=206, message=Cannot modify user <object id>.
heroku[router]: at=info method=PUT path="/parse/classes/_User/<object id>" host=<my host> request_id=<123> fwd="<123>" dyno=web.1 connect=0ms service=58ms status=400 bytes=586 protocol=https

oyvindvol avatar Sep 13 '17 09:09 oyvindvol

How is your server configuration? Do you have preventLoginWithUnverifiedEmail enabled by chance?

natanrolnik avatar Sep 13 '17 09:09 natanrolnik

@natanrolnik Yes, that is enabled.

oyvindvol avatar Sep 13 '17 09:09 oyvindvol

Please see what's discussed here: https://github.com/parse-community/parse-server/issues/4142.

This should be the expected behavior - the user returns from the server without session token, because the server won't log the user in until he verifies the email. And because he has no session token, the save call will not succeed. As a tip, you should be using saveInBackground instead of save, because save blocks the main thread.

@flovilmart another case here...

natanrolnik avatar Sep 13 '17 09:09 natanrolnik

Well, in that case I guess it shouldn`t work via Android SDK either. The properies are getting set via the Android app, but not iOS.

oyvindvol avatar Sep 13 '17 09:09 oyvindvol

Are you sure that works? You are right, it shouldn't work via Android SDK either, unless that user already got a session token at some point.

natanrolnik avatar Sep 13 '17 09:09 natanrolnik

I think so, we just registered a brand new user, and the user is not getting signed in due to the server setting, and the two properties are set, and can be viewed in our database.

The solution for me in this case then, is to set the two properties in a cloud code afterSave _User function.

oyvindvol avatar Sep 13 '17 09:09 oyvindvol

Yes, that's what I was going to suggest you, using {useMasterKey: true}.

But still, it doesn't explain why works in one platform, but not in the other.

natanrolnik avatar Sep 13 '17 10:09 natanrolnik

Can your provide the signup calls for both iOS and android when running with VERBOSE=1.

The fix is well, fixing a bad behavior, I could introduce a new error code, but that’s tedious as it needs to go through all SDK’s and I’m not sure you’d expect an error after signup.

flovilmart avatar Sep 13 '17 11:09 flovilmart

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 18 '18 11:09 stale[bot]