Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!(gotrue): change the default signOut scope to local from global #730

Merged
merged 3 commits into from
Nov 24, 2023

Conversation

dshukertjr
Copy link
Member

What kind of change does this PR introduce?

Currently when the developer calls auth.signOut(), it signs out the user from every device. This PR changes the default value to local, which is probably more aligned with what a developer would expect to happen when calling auth.signOut().

@DanMossa
Copy link
Collaborator

What exactly does global mean and how does it work? Like multiple accounts authed on the same device vs just the current active one?

Comment on lines +68 to +78
/// Determines which sessions should be logged out.
enum SignOutScope {
/// All sessions by this account will be signed out.
global,

/// Only this session will be signed out.
local,

/// All other sessions except the current one will be signed out. When using others, there is no [AuthChangeEvent.signedOut] event fired on the current session!
others,
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanMossa
Good point. Currently it's hard for the developers to understand what the scope parameter does. I have updated the comment docs like this to improve the situation.

If I am signed in on my app from a desktop and my smart phone and I call signOut(SignOutScope.global) on my phone, I will also be signed out from the desktop.

With local, I would only be signed out from the phone, and the desktop session will remain active. I think local is the behavior that typically developers would expect.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Yeah local definitely makes more sense then.

But I thought we use JWT tokens, so how would the Supabase goTrue server sign us out on other devices?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanMossa
I think it works by revoking the refresh token, so technically the sessions on other devices will be active until the access token expires.

@dshukertjr dshukertjr merged commit f5452f8 into next Nov 24, 2023
8 checks passed
@dshukertjr dshukertjr deleted the fix/signOut-scope branch November 24, 2023 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants