Issue Description
I am using the latest version of parse-server and the latest iOS SDK to create a simple sign up flow involving anonymous users. What happens is the user gets the following error when attempting to log out:
invalid session token (Code: 209, Version: 1.13.0)
Steps to reproduce
My app launches and the following code executes in my AppDelegate.swift file.
let parseConfig = ParseClientConfiguration {
$0.applicationId = "insertAppIdHere"
$0.clientKey = "insertClientKeyHere"
$0.server = "https://MyParseServer.com/parse"
}
Parse.initializeWithConfiguration(parseConfig)
PFUser.enableAutomaticUser()
PFUser.currentUser()!.saveInBackground()
There are no issues that appear to occur.
Now I Sign Up the user to convert their account from anonymous status to normal (non-anonymous) status using the signUp function in the iOS SDK. This occurs after filling in a number of fields and tapping a 'sign up' button.
let user = PFUser.currentUser()!
user.username = self.emailTextField.text
user.password = self.passwordTextField.text
user.email = self.emailTextField.text
user.signUpInBackgroundWithBlock({ (succeed, error) -> Void in
if (error == nil) {
self.dismissViewControllerAnimated(true, completion: nil)
} else {
print(error!.description)
}
})
At this point there appears to be no session token on the server. This is a problem.
And so now I tap a button to log out.
PFUser.logOutInBackgroundWithBlock({(error) -> Void in
if (error == nil) {
logOutBarButton.enabled = true
self.dismissViewControllerAnimated(true, completion: nil)
} else {
logOutBarButton.enabled = true
let errorVC = UIAlertController(title: "Oops..", message: "You Cannot Log Out at the Moment.", preferredStyle: .Alert)
errorVC.addAction(UIAlertAction(title: "OK", style: .Default, handler: { action in }))
self.presentViewController(errorVC, animated: true, completion: nil)
}
})
and get the error (as expected) in the console: invalid session token (Code: 209, Version: 1.13.0)
Expected Results
I shouldn't see an error, there should be a valid session token after sign up on the server.
Actual Outcome
invalid session token (Code: 209, Version: 1.13.0) Environment Setup
Server parse-server version: 2.2.15 Hosted on: Google App Engine
Database MongoDB version: 3.0.12 Hosted on: mLab
Additional Notes
Note that every time I did this test I made sure the database was empty. That also means I am not migrating anything from the original parse.
Logging out a second time succeeds, but I think this is because it just locally sets the currentUser to nil.
The whole thing could be a misunderstanding of how anonymous users work (further clarification would be helpful). I am almost certain though that this could have worked on original parse, since I have seen similar implementations in repositories on github. Example: (https://github.com/appflock/open/blob/master/ios/Reveal/AppDelegate.m)
How can I stop this error from occurring while using anonymous users on parse-server?
This will be hopefully be fixed with the upcoming 2.2.17