Setting custom PFUser properties after SignUp no longer works in 2.6.0/2.6.1
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
How is your server configuration?
Do you have preventLoginWithUnverifiedEmail enabled by chance?
@natanrolnik Yes, that is enabled.
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...
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.
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.
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.
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.
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.
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.