Skip to content

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

@noder199

Description

@noder199

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions