refac
This commit is contained in:
1 parent
aeb126b95d
commit
e4dbfb1276
4 files changed
+10
-11
No files matched your search
@@ -2,7 +2,6 @@
|
|||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { updateUserPassword, userSignOut } from '$lib/apis/auths';
|
import { updateUserPassword, userSignOut } from '$lib/apis/auths';
|
||||||
import { user } from '$lib/stores';
|
|
||||||
import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
|
import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
@@ -27,17 +26,13 @@
|
|||||||
// This session is no longer trusted once the password it was issued under changes
|
// This session is no longer trusted once the password it was issued under changes
|
||||||
toast.success($i18n.t('Password updated. Please sign in again.'));
|
toast.success($i18n.t('Password updated. Please sign in again.'));
|
||||||
|
|
||||||
localStorage.removeItem('token');
|
|
||||||
user.set(null);
|
|
||||||
|
|
||||||
const signOutRes = await userSignOut().catch((error) => {
|
const signOutRes = await userSignOut().catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (signOutRes?.redirect_url) {
|
localStorage.removeItem('token');
|
||||||
location.href = signOutRes.redirect_url;
|
location.href = signOutRes?.redirect_url ?? '/auth?logout=true';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPassword = '';
|
currentPassword = '';
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
location.href = res?.redirect_url ?? '/auth';
|
location.href = res?.redirect_url ?? '/auth?logout=true';
|
||||||
}}>{$i18n.t('Sign Out')}</button
|
}}>{$i18n.t('Sign Out')}</button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -573,7 +573,7 @@
|
|||||||
const res = await userSignOut();
|
const res = await userSignOut();
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
|
|
||||||
location.href = res?.redirect_url ?? '/auth';
|
location.href = res?.redirect_url ?? '/auth?logout=true';
|
||||||
show = false;
|
show = false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -155,7 +155,11 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const redirectPath = $page.url.searchParams.get('redirect');
|
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 || '/');
|
goto(redirectPath || '/');
|
||||||
} else {
|
} else {
|
||||||
if (redirectPath) {
|
if (redirectPath) {
|
||||||
@@ -175,7 +179,7 @@
|
|||||||
// deployment is unambiguously SSO-only (single provider, no login form,
|
// deployment is unambiguously SSO-only (single provider, no login form,
|
||||||
// no LDAP). Suppressed by ?form=, ?error=, onboarding, trusted-header
|
// no LDAP). Suppressed by ?form=, ?error=, onboarding, trusted-header
|
||||||
// auth, or an existing session/token.
|
// 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 ?? {});
|
const providers = Object.keys($config?.oauth?.providers ?? {});
|
||||||
if (
|
if (
|
||||||
providers.length === 1 &&
|
providers.length === 1 &&
|
||||||
|
|||||||
Reference in new issue
Block a user