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

Users signed in using OAuth have only 1 sessionToken per Sign-In

Open cipiripper opened this issue 9 years ago • 6 comments

Issue Description

We use Google OAuth to sign in users to to parse-server. We require users to be signed in from multiple devices.

If user signs in from website using his Google account (parse JS SDK), he gets session token r:AAA. Then he signs in on mobile device (parse IOS SDK), gets session token r:BBB, and token r:AAA gets removed, and website session signed out.

Problem seems to be in RestWrite.js :338, there session gets deleted from local cache, and from MongoDB as well.

This doesn't happen if user signs in using parse-server username/password combination.

Expected Results

User should have both sessions available, and active on both devices. This is how it used to be on parse.com, right?...

Actual Outcome

Only user's last session is active.

Environment Setup

  • Server

    • parse-server version: 2.6.2
    • Operating System: Ubuntu 16.04
    • Hardware: AWS EC2 c3.2xlarge instnace
    • Localhost or remote server: Remote, AWS
  • Database

    • Localhost or remote server: ObjectRocket

cipiripper avatar Nov 08 '17 13:11 cipiripper

Okay this as well RestWrite.js:

// Destroy the sessions in 'Background'
  this.config.database.destroy('_Session', {
    user: {
      __type: 'Pointer',
      className: '_User',
      objectId: this.objectId()
    },
    installationId: this.auth.installationId,
    sessionToken: { '$ne': token },
  });

So when user logs in, all his SessionTokens from this installationId get removed... Why(infinity * ?)

cipiripper avatar Nov 08 '17 16:11 cipiripper

this only destroy the session for the this.auth.installationId so should never affect other sessions that were created on other devices.

flovilmart avatar Nov 08 '17 17:11 flovilmart

~~@cipiripper Looking back in the history it looks like this was changed in #4143 to address #2885, as this was a bug and not expected functionality. You can see this is noted in the docs as well. The history there indicates this language was present in the initial commit so it probably was the same for parse.com.~~ Disregard for comment below, although the change above was for a bug fix it was not something that should have an impact on this issue.

montymxb avatar Nov 08 '17 17:11 montymxb

To agree with @flovilmart this shouldn't cause you a problem as it's just clearing duplicates for multiple sessions with the same installationId. The device and browser session shouldn't conflict with each other in this regard, unless a matching installationId was being set onto the web session for some reason.

montymxb avatar Nov 08 '17 19:11 montymxb

Thanks for your feedback guys, I will investigate this some more...

cipiripper avatar Nov 08 '17 19:11 cipiripper

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 10:09 stale[bot]