From 5bb1c470802c7df9a48cc0ca45c1886c294d6e6e Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 5 Oct 2026 12:49:11 +0400 Subject: [PATCH] refac --- .../admin/Settings/Authentication.svelte | 37 ++++- .../components/admin/Settings/General.svelte | 26 +--- .../admin/Users/UserList/EditUserModal.svelte | 2 +- src/lib/components/auth/MfaChallenge.svelte | 16 +- .../components/auth/MfaRecoveryCodes.svelte | 8 +- .../chat/Settings/Account/Mfa.svelte | 2 +- src/lib/components/workspace/Models.svelte | 138 ++++++++++++------ .../workspace/Models/ModelMenu.svelte | 8 +- src/lib/i18n/locales/en-US/translation.json | 2 + src/routes/auth/+page.svelte | 4 +- 10 files changed, 152 insertions(+), 91 deletions(-) diff --git a/src/lib/components/admin/Settings/Authentication.svelte b/src/lib/components/admin/Settings/Authentication.svelte index 189cb55e81..0132e15b11 100644 --- a/src/lib/components/admin/Settings/Authentication.svelte +++ b/src/lib/components/admin/Settings/Authentication.svelte @@ -92,6 +92,11 @@ toast.error(`${error}`); return null; }); + if (res?.sessions_revoked) { + localStorage.removeItem('token'); + window.location.href = '/auth?state=logout&form=signin'; + return false; + } if (res) { adminConfig = res; } @@ -99,11 +104,13 @@ }; const submitHandler = async () => { - const adminSaved = await updateAdminHandler(); const ldapSaved = await updateLdapServerHandler(); const oauthSaved = await updateOAuthHandler(); + if (!ldapSaved || !oauthSaved) return; - if (adminSaved && ldapSaved && oauthSaved) { + // Save MFA policy last because changing it revokes the current session. + const adminSaved = await updateAdminHandler(); + if (adminSaved) { toast.success($i18n.t('Settings saved successfully!')); await config.set(await getBackendConfig()); } @@ -255,6 +262,32 @@ + + + + +

+ {$i18n.t('Changes sign out all devices. Users enroll on their next sign-in.')} +

+ {#if adminConfig.ENABLE_MFA} + + + {/if} +
+ diff --git a/src/lib/components/admin/Settings/General.svelte b/src/lib/components/admin/Settings/General.svelte index 570d834e8c..3e269aa9e5 100644 --- a/src/lib/components/admin/Settings/General.svelte +++ b/src/lib/components/admin/Settings/General.svelte @@ -275,31 +275,7 @@ {/if} - - - - -

- {$i18n.t('Changes sign out all devices. Users enroll on their next sign-in.')} -

- {#if adminConfig.ENABLE_MFA} - - - {/if} -
+ {:else}
-

+

{$i18n.t( challenge.next_step === 'enroll' ? 'Set up your authenticator' @@ -103,7 +103,7 @@ />
{$i18n.t('Enter the key manually')} @@ -118,11 +118,11 @@

{:else}{/if} {/if} -