Open maxhvlm opened 2 years ago
Looks like the same issue as https://github.com/supabase/gotrue-js/issues/518. Be sure to checkout the last two comments.
Hey @maxhvlm, I've tried to reproduce this on the react example in gotrue-js by moving the onAuthStateChange
method into a useEffect
block as you described (https://github.com/supabase/gotrue-js/blob/a831a356dbef665d8d6e3285c96346494628dd72/example/react/src/App.js#L24-L27) but to no avail. Do you happen to have a repo that I can check out to reproduce this error?
Bug report
Describe the bug
When signing up using email, the user successfully gets redirected to the redirectTo link specified with the correct access and refresh tokens. They get picked up by supabase and the session gets saved to the localstorage. However no
onAuthStateChange
event is fired, only after refreshing the page the session gets parsed from the local storage and the event is fired.To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
useEffect(() => { supabase.auth.onAuthStateChange((_event, session) => { console.log("Got session form onAuthStateChange", session, _event); }); }, []);
2.. Call supabase.auth.signup to generate the emailsupabase.auth.signUp({ email, password }, { redirectTo: "{our_url}/login"})
Expected behavior
Once supabase obtains a valid session and updates it in the localstorage, the onAuthStateChange should get fired.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
Additional context
We're trying to redirect the user back to the login screen after successful signup as we have a hook that checks if a session already exists and redirect users either to the appropriate homepage (profile signup, dashboard, ...).
However this functionality isn't working as no session is set after accessing the page from the email signup link.