mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
Merge pull request #11950 from shirayu/feat_auth_redirect
feat: Adding auth redirect parameter
This commit is contained in:
commit
d81d1333ba
@ -496,6 +496,9 @@
|
|||||||
if ($config) {
|
if ($config) {
|
||||||
await setupSocket($config.features?.enable_websocket ?? true);
|
await setupSocket($config.features?.enable_websocket ?? true);
|
||||||
|
|
||||||
|
const currentUrl = `${window.location.pathname}${window.location.search}`;
|
||||||
|
const encodedUrl = encodeURIComponent(currentUrl);
|
||||||
|
|
||||||
if (localStorage.token) {
|
if (localStorage.token) {
|
||||||
// Get Session User Info
|
// Get Session User Info
|
||||||
const sessionUser = await getSessionUser(localStorage.token).catch((error) => {
|
const sessionUser = await getSessionUser(localStorage.token).catch((error) => {
|
||||||
@ -512,13 +515,13 @@
|
|||||||
} else {
|
} else {
|
||||||
// Redirect Invalid Session User to /auth Page
|
// Redirect Invalid Session User to /auth Page
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
await goto('/auth');
|
await goto(`/auth?redirect=${encodedUrl}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Don't redirect if we're already on the auth page
|
// Don't redirect if we're already on the auth page
|
||||||
// Needed because we pass in tokens from OAuth logins via URL fragments
|
// Needed because we pass in tokens from OAuth logins via URL fragments
|
||||||
if ($page.url.pathname !== '/auth') {
|
if ($page.url.pathname !== '/auth') {
|
||||||
await goto('/auth');
|
await goto(`/auth?redirect=${encodedUrl}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user