I'm trying to do a very simple workflow with magic links:
1) User requests a magic link:
let { user, error } = await supabaseClient.auth.signIn({
email: email
})
2) User receives email and clicks link. After authentication user is redirected to our site.
3) Try to get user on the client using:
supabaseClient.auth.user()
But no user is returned (it's null). What am I doing wrong?
g
garyaustin
03/02/2022, 2:45 PM
Is your auth.user() code running in the browser (versus server)? Is the session info in localstorage and if so is user object there?
i
irrationaljared
03/02/2022, 2:48 PM
It is running in the browser, yes. How can I check if the session info is in localstorage? Is there an additional step you need to take to put it in localstorage?
g
garyaustin
03/02/2022, 2:51 PM
Should see storage object from your address:
i
irrationaljared
03/03/2022, 2:02 PM
It looks like it was a timing issue. I was requesting the user before it was available. I've commented that this might be worth putting in the documentation as my expectation would have been that as soon as the redirect happened after authentication then the user would be available. As it is now I have to use some mildly awkward spinners so that I don't flash the login page before showing the real content because the user object is available a second after the page loads...