fmontanari
03/25/2022, 7:56 PM/user/profile
) and want to check if the current user is authenticated:
js
async function isAuthenticated() {
// User has session?
if(supabase.auth.session == null) {
// We don't, check if there's an old session in storage (local/session Storage)
const oldSession = getStorageSession();
// Has it expired yet?
if (oldSession.expiresAt >= Date.now()) {
loginWithRefreshToken();
return true;
}
else {
// setAuth with old session (does Supabase handle this automatically?)
await supabase.auth.setAuth(oldSession.access_token);
return true;
}
}
else {
// We have a session, is it expired though?
if(supabase.auth.session.expiresAt >= Date.now() {
loginWithRefreshToken();
return true;
}
}
// On error logging in with refresh token, returns false.
}
However, I receive "Invalid access token" after trying to login with the refresh token... Is there any step I'm missing, or is there any misunderstandings with how I should handle authentication with Supabase Auth?Needle
03/25/2022, 7:56 PM/title
command!
We have solved your problem?
Click the button below to archive it.Needle
03/25/2022, 7:57 PM