Use setSession from hash tokens before exchange
cgen-f249e8cfc26646d58d72275d0e2d493b
This commit is contained in:
parent
8fc012ee9c
commit
b011b673a4
1 changed files with 15 additions and 5 deletions
|
|
@ -46,11 +46,21 @@ export default function ResetPassword() {
|
|||
setLinkError(urlErrorDesc || "Reset link is invalid or has expired.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await supabase.auth.exchangeCodeForSession(window.location.href);
|
||||
} catch (e: any) {
|
||||
setLinkError("Reset link is invalid or has expired.");
|
||||
return;
|
||||
const access_token = params.get("access_token");
|
||||
const refresh_token = params.get("refresh_token");
|
||||
if (access_token && refresh_token) {
|
||||
const { error: setErr } = await supabase.auth.setSession({ access_token, refresh_token });
|
||||
if (setErr) {
|
||||
setLinkError("Reset link is invalid or has expired.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await supabase.auth.exchangeCodeForSession(window.location.href);
|
||||
} catch (e: any) {
|
||||
setLinkError("Reset link is invalid or has expired.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
const { data } = await supabase.auth.getSession();
|
||||
if (!data?.session) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue