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: make supabase.auth.onAuthStateChange work across browser windows #127

Closed
wants to merge 1 commit into from

Conversation

i-pip
Copy link

@i-pip i-pip commented Aug 27, 2021

What kind of change does this PR introduce?

Bug fix: ensure onAuthStateChange works across multiple browser windows

What is the current behavior?

Addresses #2739 - "onAuthStateChange does not catch auth state changes across multiple windows"

What is the new behavior?

2021-08-27_16-13-41 (1)

@Andarist
Copy link
Contributor

Andarist commented Sep 4, 2021

Note that it might not work if a custom localStorage is provided. So I wonder if this shouldn't listen on a separate key and not on the one responsible for storing the token. That way you could still preserve the token in a different type of storage (like cookies) while being able to broadcast the notification using the localStorage "channel"

@kiwicopple
Copy link
Member

@Andarist I think for that to work the other storage provider would need to implement some sort of pub/sub functionality?

I can't think of a way that this could work with cookies - do you have some code that you can share which would clarify how it might function?

@kiwicopple
Copy link
Member

Thanks for this @i-pip ! I added your code here : #184

Made a new PR so I could tidy it up a bit. If you get a chance would love you to test out that PR and make sure it's good !

@kiwicopple kiwicopple closed this Nov 18, 2021
@i-pip i-pip deleted the fix/authStateChange branch December 29, 2021 11:23
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.

3 participants