Add support for OAuth redirect destination from sessionStorage
cgen-c246145e22f04784a62477f2ebc383c3
This commit is contained in:
parent
6457e7479b
commit
c3ccf53d07
1 changed files with 14 additions and 2 deletions
|
|
@ -105,8 +105,20 @@ export default function Login() {
|
|||
if (!loading && user) {
|
||||
const params = new URLSearchParams(location.search);
|
||||
const next = params.get("next");
|
||||
const safeNext = next && next.startsWith("/") ? next : null;
|
||||
navigate(safeNext || (profileComplete ? "/dashboard" : "/onboarding"), {
|
||||
|
||||
// Check if there's an OAuth redirect destination stored (e.g., from staff login)
|
||||
const oauthRedirect = sessionStorage.getItem("oauth_redirect_to");
|
||||
const redirectDest =
|
||||
(next && next.startsWith("/") ? next : null) ||
|
||||
oauthRedirect ||
|
||||
(profileComplete ? "/dashboard" : "/onboarding");
|
||||
|
||||
// Clear the stored redirect after using it
|
||||
if (oauthRedirect) {
|
||||
sessionStorage.removeItem("oauth_redirect_to");
|
||||
}
|
||||
|
||||
navigate(redirectDest, {
|
||||
replace: true,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue