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

Potential Bug: invalid session token (Code: 209, Version: 1.13.0) when using Anonymous Users

Open noder199 opened this issue 10 years ago • 1 comments

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

  1. 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.

  1. 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.

  1. 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
    • Operating System: Whichever Google Compute Engine uses
    • Hardware: Google App Engine (Google Compute Engine instances)
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Google App Engine
  • Database
    • MongoDB version: 3.0.12
    • Storage engine: mLab
    • Hardware: mLab
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

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. Additional Note: Logging out a second time succeeds, but I think this is because it just locally sets the currentUser to nil.

Logs/Trace

You can turn on additional logging by configuring VERBOSE=1 in your environment.

Not gonna bother with logging unless this actually appears to be a bug.

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)

noder199 avatar Jul 02 '16 23:07 noder199

This seems to be related to your other issue #2252 and fixed by the PR #2266. I'll close for now. Reopen if it is not solved with the release of 2.2.17

flovilmart avatar Jul 16 '16 04:07 flovilmart