ФУНКЦИИ - NODEDC LAUNCHER: preserve auth returnTo
This commit is contained in:
parent
a1e8cacd88
commit
8e6d2cea39
|
|
@ -187,7 +187,7 @@ export function LauncherApp() {
|
|||
useEffect(() => {
|
||||
if (!authSession || authSession.authenticated) return;
|
||||
|
||||
window.location.replace(authSession.loginUrl || "/auth/login");
|
||||
window.location.replace(buildLoginRedirectUrl(authSession.loginUrl));
|
||||
}, [authSession]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -658,3 +658,17 @@ function AuthStateScreen({
|
|||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function buildLoginRedirectUrl(loginUrl?: string) {
|
||||
const url = new URL(loginUrl || "/auth/login", window.location.origin);
|
||||
|
||||
if (!url.searchParams.has("returnTo")) {
|
||||
const returnTo = `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
||||
|
||||
if (returnTo && returnTo !== "/") {
|
||||
url.searchParams.set("returnTo", returnTo);
|
||||
}
|
||||
}
|
||||
|
||||
return url.origin === window.location.origin ? `${url.pathname}${url.search}${url.hash}` : url.toString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue