-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
Support for multiple tabs does NOT respect the 'persistSession' option across tabs #294
Comments
Hey @chipilov, could you please clarify how your application managed to get into a state where the Thanks for taking the time to do such a detailed write-up of the issue btw! |
Hi @kangmingtay, In my app, I set the
NOTE, that you can also get in the same situation even if the default for
Let me know if anything is unclear. |
This is behavior that is not something the library can provide. You should synchronize the "remember me" state across tabs manually. We may consider having some explicit form of "remember me" implemented in the next major version, but that is far away. |
Bug report
Describe the bug
Supabase's GoTrue JavaScript client has explicit support for multiple tabs which is enabled by default.
Supabase's GoTrue JavaScript client also has support for the commonly-used 'Remember Me' feature via the
persistSession
parameter of theSupabaseAuthClient
constructor.The issue is that if a user has 2 tabs open - one where the auth client has the
persistSession
set tofalse
and one where the parameter is set totrue
- the different tabs will continue to behave differently in terms of persisting the session EVEN though logging from one tab will automatically log-in the other tab.To me, it seems that it's more logical that once a user logs-in via tab A, all other tabs that get automatically logged-in will inherit the
persistSession
behavior of the tab A.To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
persistSession
is set totrue
(let's call this tab A) and one wherepersistSession
is set tofalse
(let's call this tab B)Expected behavior
The client is still signed-in because when they signed-in originally via tab A, they chose to be remembered (i.e. the
persistSession
parameter wastrue
);Actual behavior
The client is no longer signed-in and needs to sign-in again.
Consequences
This behavior can lead to failed token refresh requests because of the re-use of an invalidated refresh token.
This can happen when tab A (as defined above) is closed and its token remains in localStorage while tab B continues to send token refresh requests without updating the token in localStorage. Hence, localStorage will be left with a stale refresh token which will be incorrectly re-used in at least one of 2 cases:
SupabaseAuthClient
object, this new object will try to use the refresh token in local storage to recover the session with the stale refresh token (see https://github.com/supabase/gotrue-js/blob/30fb5729a1988dbd7f61d58ec10eb81de63f93c7/src/GoTrueClient.ts#L107)The problem is made worse for users of the library because the library does NOT expose the persistSession config - this means that users of the library can only work around this by inspecting the data in localStorage for which there is also no publicly defined API as far as I can tell.
System information
The text was updated successfully, but these errors were encountered: