mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-02 12:14:48 +02:00
refac
This commit is contained in:
@@ -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 = '';
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user