fix: redirect to original page after re-authentication (#1959)

* fix: redirect to original page after re-authentication

When a session expires, the current URL is now preserved as a query
parameter on the login page. After successful login (including MFA
flows), the user is redirected back to their original page instead of
always landing on /home.

* secure

---------

Co-authored-by: Julien Fontanet <julien.fontanet@isonoe.net>
This commit is contained in:
Philip Okugbe
2026-02-21 00:02:23 +00:00
committed by GitHub
parent d6472f0876
commit 53132acb0a
8 changed files with 42 additions and 20 deletions
+16
View File
@@ -29,4 +29,20 @@ const APP_ROUTE = {
},
};
export function getPostLoginRedirect(): string {
const params = new URLSearchParams(window.location.search);
const redirect = params.get("redirect");
if (redirect) {
try {
const resolved = new URL(redirect, window.location.origin);
if (resolved.origin === window.location.origin) {
return resolved.pathname + resolved.search + resolved.hash;
}
} catch {
// malformed URL, fall through to default
}
}
return APP_ROUTE.HOME;
}
export default APP_ROUTE;