mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat: auth logout page (#27831)
* feat: auth logout page * feat: skip login if already logged in
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import AuthPageLayout from '$lib/components/layouts/AuthPageLayout.svelte';
|
||||
import { authManager } from '$lib/managers/auth-manager.svelte';
|
||||
import { Route } from '$lib/route';
|
||||
import { updateMyUser } from '@immich/sdk';
|
||||
import { Alert, Button, Field, HelperText, PasswordInput, Stack, Text } from '@immich/ui';
|
||||
import { t } from 'svelte-i18n';
|
||||
@@ -23,7 +25,7 @@
|
||||
}
|
||||
|
||||
await updateMyUser({ userUpdateMeDto: { password } });
|
||||
await authManager.logout();
|
||||
await goto(Route.logout());
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { authManager } from '$lib/managers/auth-manager.svelte';
|
||||
import { serverConfigManager } from '$lib/managers/server-config-manager.svelte';
|
||||
import { Route } from '$lib/route';
|
||||
import { getFormatter } from '$lib/utils/i18n';
|
||||
@@ -7,6 +8,11 @@ import type { PageLoad } from './$types';
|
||||
export const load = (async ({ parent, url }) => {
|
||||
await parent();
|
||||
|
||||
const continueUrl = url.searchParams.get('continue') || Route.photos();
|
||||
if (authManager.authenticated) {
|
||||
redirect(307, continueUrl);
|
||||
}
|
||||
|
||||
if (!serverConfigManager.value.isInitialized) {
|
||||
// Admin not registered
|
||||
redirect(307, Route.register());
|
||||
@@ -17,6 +23,6 @@ export const load = (async ({ parent, url }) => {
|
||||
meta: {
|
||||
title: $t('login'),
|
||||
},
|
||||
continueUrl: url.searchParams.get('continue') || Route.photos(),
|
||||
continueUrl,
|
||||
};
|
||||
}) satisfies PageLoad;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { authManager } from '$lib/managers/auth-manager.svelte';
|
||||
import { LoadingSpinner } from '@immich/ui';
|
||||
|
||||
void authManager.logout();
|
||||
</script>
|
||||
|
||||
<div class="h-screen w-screen overflow-hidden">
|
||||
<div class="m-auto">
|
||||
<LoadingSpinner />
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user