-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
user() is null on first invocation after Magic Link sign in #143
Comments
I think the problem goes deeper than this and doesn't only affect magic links. The issue is that on initial page load, there are 3 possible scenarios:
Unless I am missing something, there is no way for a developer to differentiate between (1) and (3) if supabase.auth.user() returns null. If it is (3) then you don't want to redirect the user to a login page because you just need to wait a bit until their token is refreshed (i.e. wait until onAuthStateChanged() is fired). If it is (1), however, you do want to redirect them. It seems to me that the only way to currently know what to do is to manually inspect local storage to see if there is a token inside. However, this does NOT seem like a good option since it relies on the internals of the GoTrue client. Regarding @joanllenas 's suggestions above:
|
Is there something new on this issue? Since using supabase i'm facing this issue that the first request for the session is null. |
This is also an issue for me with Facebook. I think if gotrue just opened the OAuth provider in another tab it would work. The redirects by the providers break the OAuth State Listener. |
Here are some instances of people complaining about this issue on the web.
I'm sure I could find more, but I hope this highlights that this is a long ongoing issue. |
Seems like this is the base issue: #460 |
🎉 This issue has been resolved in version 1.23.0-next.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 2.0.0-rc.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This issue has been inactive for a while and I believe the underlying issues have already been addressed with version 2. |
Bug report
Describe the bug
When you sign in via Magic Link from an email, the user is
null
initially.In order to successfully initialize my app I have to use a
setTimeout
:To Reproduce
Expected behavior
I would say that there are at least two possible expected behaviours:
supabase.auth.user()
is synchronous for all cases.'NOT_SIGNED_IN'
event tosupabase.auth.onAuthStateChange
.System information
Additional context
Related to #23
The text was updated successfully, but these errors were encountered: