feat: Added redirect parameter to /auth

This commit is contained in:
Yuta Hayashibe 2025-03-22 14:59:17 +09:00
parent f872bda19b
commit 966940cb00
No known key found for this signature in database
GPG Key ID: CD83C5CFA6802211

View File

@ -496,6 +496,9 @@
if ($config) {
await setupSocket($config.features?.enable_websocket ?? true);
const currentUrl = `${window.location.pathname}${window.location.search}`;
const encodedUrl = encodeURIComponent(currentUrl);
if (localStorage.token) {
// Get Session User Info
const sessionUser = await getSessionUser(localStorage.token).catch((error) => {
@ -512,13 +515,13 @@
} else {
// Redirect Invalid Session User to /auth Page
localStorage.removeItem('token');
await goto('/auth');
await goto(`/auth?redirect=${encodedUrl}`);
}
} else {
// Don't redirect if we're already on the auth page
// Needed because we pass in tokens from OAuth logins via URL fragments
if ($page.url.pathname !== '/auth') {
await goto('/auth');
await goto(`/auth?redirect=${encodedUrl}`);
}
}
}