From e4dbfb1276c80e301881e9c2f4d313bdf89a99a9 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 30 Aug 2026 23:50:30 -0400 Subject: [PATCH] refac --- .../chat/Settings/Account/UpdatePassword.svelte | 9 ++------- src/lib/components/layout/Overlay/AccountPending.svelte | 2 +- src/lib/components/layout/Sidebar/UserMenu.svelte | 2 +- src/routes/auth/+page.svelte | 8 ++++++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/lib/components/chat/Settings/Account/UpdatePassword.svelte b/src/lib/components/chat/Settings/Account/UpdatePassword.svelte index 099c7694d2..f35cc5e7e2 100644 --- a/src/lib/components/chat/Settings/Account/UpdatePassword.svelte +++ b/src/lib/components/chat/Settings/Account/UpdatePassword.svelte @@ -2,7 +2,6 @@ import { getContext } from 'svelte'; import { toast } from 'svelte-sonner'; import { updateUserPassword, userSignOut } from '$lib/apis/auths'; - import { user } from '$lib/stores'; import SensitiveInput from '$lib/components/common/SensitiveInput.svelte'; const i18n = getContext('i18n'); @@ -27,17 +26,13 @@ // This session is no longer trusted once the password it was issued under changes toast.success($i18n.t('Password updated. Please sign in again.')); - localStorage.removeItem('token'); - user.set(null); - const signOutRes = await userSignOut().catch((error) => { console.error(error); return null; }); - if (signOutRes?.redirect_url) { - location.href = signOutRes.redirect_url; - } + localStorage.removeItem('token'); + location.href = signOutRes?.redirect_url ?? '/auth?logout=true'; } currentPassword = ''; diff --git a/src/lib/components/layout/Overlay/AccountPending.svelte b/src/lib/components/layout/Overlay/AccountPending.svelte index bb81b42186..1809579324 100644 --- a/src/lib/components/layout/Overlay/AccountPending.svelte +++ b/src/lib/components/layout/Overlay/AccountPending.svelte @@ -75,7 +75,7 @@ return null; }); localStorage.removeItem('token'); - location.href = res?.redirect_url ?? '/auth'; + location.href = res?.redirect_url ?? '/auth?logout=true'; }}>{$i18n.t('Sign Out')} diff --git a/src/lib/components/layout/Sidebar/UserMenu.svelte b/src/lib/components/layout/Sidebar/UserMenu.svelte index 0b95e62b35..1be9cf7fbe 100644 --- a/src/lib/components/layout/Sidebar/UserMenu.svelte +++ b/src/lib/components/layout/Sidebar/UserMenu.svelte @@ -573,7 +573,7 @@ const res = await userSignOut(); localStorage.removeItem('token'); - location.href = res?.redirect_url ?? '/auth'; + location.href = res?.redirect_url ?? '/auth?logout=true'; show = false; }} > diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index 0dc9439b04..d5ccd33076 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -155,7 +155,11 @@ onMount(async () => { const redirectPath = $page.url.searchParams.get('redirect'); - if ($user) { + const logout = $page.url.searchParams.get('logout') === 'true'; + + if (logout) { + await user.set(null); + } else if ($user) { goto(redirectPath || '/'); } else { if (redirectPath) { @@ -175,7 +179,7 @@ // deployment is unambiguously SSO-only (single provider, no login form, // no LDAP). Suppressed by ?form=, ?error=, onboarding, trusted-header // auth, or an existing session/token. - if ($config?.oauth?.auto_redirect && !form && !error) { + if ($config?.oauth?.auto_redirect && !logout && !form && !error) { const providers = Object.keys($config?.oauth?.providers ?? {}); if ( providers.length === 1 &&