This commit is contained in:
Timothy Jaeryang Baek
2026-08-30 23:50:30 -04:00
parent aeb126b95d
commit e4dbfb1276
4 changed files with 10 additions and 11 deletions

View File

@@ -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 = '';

View File

@@ -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')}</button
>
</div>

View File

@@ -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;
}}
>

View File

@@ -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 &&