From c602eaea4aa0aab10913cd605362a948956a85e7 Mon Sep 17 00:00:00 2001 From: martin <74269598+martabal@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:35:28 +0100 Subject: [PATCH] feat(web): automatically update user info (#5647) * use svelte store * fix: websocket error when not authenticated * more routes --- .../storage-template-settings.svelte | 12 ++++---- .../components/album-page/album-card.svelte | 4 +-- .../asset-viewer/asset-viewer-nav-bar.svelte | 4 +-- .../layouts/user-page-layout.svelte | 4 +-- .../navigation-bar/account-info-panel.svelte | 2 ++ .../navigation-bar/navigation-bar.svelte | 17 ++++++----- .../user-profile-settings.svelte | 2 ++ .../user-settings-list.svelte | 13 ++++----- web/src/lib/stores/user.store.ts | 4 +-- web/src/lib/stores/websocket.ts | 3 +- web/src/lib/utils/auth.ts | 11 +++++-- web/src/routes/(user)/albums/+page.svelte | 8 ++--- web/src/routes/(user)/albums/+page.ts | 3 +- .../(user)/albums/[albumId]/+page.svelte | 6 ++-- .../routes/(user)/albums/[albumId]/+page.ts | 3 +- web/src/routes/(user)/archive/+page.svelte | 2 +- web/src/routes/(user)/archive/+page.ts | 3 +- web/src/routes/(user)/explore/+page.svelte | 2 +- web/src/routes/(user)/explore/+page.ts | 3 +- web/src/routes/(user)/favorites/+page.svelte | 2 +- web/src/routes/(user)/favorites/+page.ts | 3 +- web/src/routes/(user)/map/+page.svelte | 2 +- web/src/routes/(user)/map/+page.ts | 3 +- .../routes/(user)/partners/[userId]/+page.ts | 3 +- web/src/routes/(user)/people/+page.svelte | 2 +- web/src/routes/(user)/people/+page.ts | 3 +- .../routes/(user)/people/[personId]/+page.ts | 3 +- web/src/routes/(user)/photos/+page.svelte | 10 +++---- web/src/routes/(user)/photos/+page.ts | 3 +- web/src/routes/(user)/search/+page.svelte | 2 +- web/src/routes/(user)/search/+page.ts | 3 +- .../routes/(user)/share/[key]/+page.svelte | 6 ++-- web/src/routes/(user)/share/[key]/+page.ts | 3 +- web/src/routes/(user)/sharing/+page.svelte | 4 +-- web/src/routes/(user)/sharing/+page.ts | 3 +- .../(user)/sharing/sharedlinks/+page.ts | 3 +- web/src/routes/(user)/trash/+page.svelte | 2 +- web/src/routes/(user)/trash/+page.ts | 3 +- .../routes/(user)/user-settings/+page.svelte | 4 +-- web/src/routes/(user)/user-settings/+page.ts | 3 +- web/src/routes/+layout.svelte | 5 ++-- web/src/routes/+layout.ts | 19 ------------ web/src/routes/admin/jobs-status/+page.svelte | 2 +- web/src/routes/admin/jobs-status/+page.ts | 3 +- web/src/routes/admin/repair/+page.svelte | 2 +- web/src/routes/admin/repair/+page.ts | 3 +- .../routes/admin/server-status/+page.svelte | 2 +- web/src/routes/admin/server-status/+page.ts | 3 +- .../routes/admin/system-settings/+page.svelte | 8 ++--- web/src/routes/admin/system-settings/+page.ts | 3 +- .../routes/admin/user-management/+page.svelte | 29 ++++++++++--------- web/src/routes/admin/user-management/+page.ts | 3 +- .../routes/auth/change-password/+page.svelte | 5 ++-- web/src/routes/auth/change-password/+page.ts | 6 ++-- 54 files changed, 114 insertions(+), 155 deletions(-) diff --git a/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte b/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte index 5bdef1f5e5..34f556c06a 100644 --- a/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte +++ b/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte @@ -1,5 +1,5 @@ - + @@ -42,7 +41,7 @@ - + {#if $featureFlags.loaded && $featureFlags.oauth} @@ -51,7 +50,7 @@ subtitle="Manage your OAuth connection" isOpen={oauthOpen || $page.url.searchParams.get('open') === 'oauth'} > - + {/if} @@ -60,7 +59,7 @@ - + diff --git a/web/src/lib/stores/user.store.ts b/web/src/lib/stores/user.store.ts index 3a73f4d9ab..0b886746e2 100644 --- a/web/src/lib/stores/user.store.ts +++ b/web/src/lib/stores/user.store.ts @@ -1,9 +1,9 @@ import { get, writable } from 'svelte/store'; import type { UserResponseDto } from '@api'; -export const user = writable(null); +export const user = writable(); -export const setUser = (value: UserResponseDto | null) => { +export const setUser = (value: UserResponseDto) => { user.set(value); }; diff --git a/web/src/lib/stores/websocket.ts b/web/src/lib/stores/websocket.ts index 3bfa199cfd..5871771e8d 100644 --- a/web/src/lib/stores/websocket.ts +++ b/web/src/lib/stores/websocket.ts @@ -2,6 +2,7 @@ import type { AssetResponseDto, ServerVersionResponseDto } from '@api'; import { Socket, io } from 'socket.io-client'; import { writable } from 'svelte/store'; import { loadConfig } from './server-config.store'; +import { getSavedUser } from './user.store'; export interface ReleaseEvent { isAvailable: boolean; @@ -25,7 +26,7 @@ let websocket: Socket | null = null; export const openWebsocketConnection = () => { try { - if (websocket) { + if (websocket || !getSavedUser()) { return; } diff --git a/web/src/lib/utils/auth.ts b/web/src/lib/utils/auth.ts index ae3b56ac9a..09e5cd3e7a 100644 --- a/web/src/lib/utils/auth.ts +++ b/web/src/lib/utils/auth.ts @@ -34,8 +34,13 @@ export const authenticate = async (options?: AuthOptions) => { if (!savedUser) { setUser(user); } - - return user; }; -export const isLoggedIn = async () => getAuthUser().then((user) => !!user); +export const isLoggedIn = async () => { + const savedUser = getSavedUser(); + const user = savedUser || (await getAuthUser()); + if (!savedUser) { + setUser(user); + } + return user; +}; diff --git a/web/src/routes/(user)/albums/+page.svelte b/web/src/routes/(user)/albums/+page.svelte index 162133c388..2979b7a6fb 100644 --- a/web/src/routes/(user)/albums/+page.svelte +++ b/web/src/routes/(user)/albums/+page.svelte @@ -245,7 +245,7 @@ {/if} - +
@@ -291,11 +291,7 @@ diff --git a/web/src/routes/(user)/albums/+page.ts b/web/src/routes/(user)/albums/+page.ts index 037fc1ef68..5b12ad2601 100644 --- a/web/src/routes/(user)/albums/+page.ts +++ b/web/src/routes/(user)/albums/+page.ts @@ -3,11 +3,10 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate(); + await authenticate(); const { data: albums } = await api.albumApi.getAllAlbums(); return { - user, albums, meta: { title: 'Albums', diff --git a/web/src/routes/(user)/albums/[albumId]/+page.svelte b/web/src/routes/(user)/albums/[albumId]/+page.svelte index 9638e1386c..0293163874 100644 --- a/web/src/routes/(user)/albums/[albumId]/+page.svelte +++ b/web/src/routes/(user)/albums/[albumId]/+page.svelte @@ -109,8 +109,8 @@ const timelineInteractionStore = createAssetInteractionStore(); const { selectedAssets: timelineSelected } = timelineInteractionStore; - $: isOwned = data.user.id == album.ownerId; - $: isAllUserOwned = Array.from($selectedAssets).every((asset) => asset.ownerId === data.user.id); + $: isOwned = $user.id == album.ownerId; + $: isAllUserOwned = Array.from($selectedAssets).every((asset) => asset.ownerId === $user.id); $: isAllFavorite = Array.from($selectedAssets).every((asset) => asset.isFavorite); $: { if (isShowActivity) { @@ -343,7 +343,7 @@ }; const handleRemoveUser = async (userId: string) => { - if (userId == 'me' || userId === data.user.id) { + if (userId == 'me' || userId === $user.id) { goto(backUrl); return; } diff --git a/web/src/routes/(user)/albums/[albumId]/+page.ts b/web/src/routes/(user)/albums/[albumId]/+page.ts index 8a6e4913f3..e2b0783994 100644 --- a/web/src/routes/(user)/albums/[albumId]/+page.ts +++ b/web/src/routes/(user)/albums/[albumId]/+page.ts @@ -3,12 +3,11 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { - const user = await authenticate(); + await authenticate(); const { data: album } = await api.albumApi.getAlbumInfo({ id: params.albumId, withoutAssets: true }); return { album, - user, meta: { title: album.albumName, }, diff --git a/web/src/routes/(user)/archive/+page.svelte b/web/src/routes/(user)/archive/+page.svelte index 08f081ebd0..0d3714a021 100644 --- a/web/src/routes/(user)/archive/+page.svelte +++ b/web/src/routes/(user)/archive/+page.svelte @@ -44,7 +44,7 @@ {/if} - + { - const user = await authenticate(); + await authenticate(); return { - user, meta: { title: 'Archive', }, diff --git a/web/src/routes/(user)/explore/+page.svelte b/web/src/routes/(user)/explore/+page.svelte index db1f63fae9..580ff70b2f 100644 --- a/web/src/routes/(user)/explore/+page.svelte +++ b/web/src/routes/(user)/explore/+page.svelte @@ -36,7 +36,7 @@ - + {#if hasPeople}
diff --git a/web/src/routes/(user)/explore/+page.ts b/web/src/routes/(user)/explore/+page.ts index a89ac8c834..b36dc69c32 100644 --- a/web/src/routes/(user)/explore/+page.ts +++ b/web/src/routes/(user)/explore/+page.ts @@ -3,11 +3,10 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate(); + await authenticate(); const { data: items } = await api.searchApi.getExploreData(); const { data: response } = await api.personApi.getAllPeople({ withHidden: false }); return { - user, items, response, meta: { diff --git a/web/src/routes/(user)/favorites/+page.svelte b/web/src/routes/(user)/favorites/+page.svelte index b586e985a8..4005a5d81c 100644 --- a/web/src/routes/(user)/favorites/+page.svelte +++ b/web/src/routes/(user)/favorites/+page.svelte @@ -49,7 +49,7 @@ {/if} - + { - const user = await authenticate(); + await authenticate(); return { - user, meta: { title: 'Favorites', }, diff --git a/web/src/routes/(user)/map/+page.svelte b/web/src/routes/(user)/map/+page.svelte index 2b1f989b5a..cb5148aa13 100644 --- a/web/src/routes/(user)/map/+page.svelte +++ b/web/src/routes/(user)/map/+page.svelte @@ -101,7 +101,7 @@ {#if $featureFlags.loaded && $featureFlags.map} - +
onViewAssets(event.detail)} />
{ - const user = await authenticate(); + await authenticate(); return { - user, meta: { title: 'Map', }, diff --git a/web/src/routes/(user)/partners/[userId]/+page.ts b/web/src/routes/(user)/partners/[userId]/+page.ts index 6bbbdd42d1..9a96109e73 100644 --- a/web/src/routes/(user)/partners/[userId]/+page.ts +++ b/web/src/routes/(user)/partners/[userId]/+page.ts @@ -3,12 +3,11 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { - const user = await authenticate(); + await authenticate(); const { data: partner } = await api.userApi.getUserById({ id: params.userId }); return { - user, partner, meta: { title: 'Partner', diff --git a/web/src/routes/(user)/people/+page.svelte b/web/src/routes/(user)/people/+page.svelte index 2738eeabb6..19f26e6b97 100644 --- a/web/src/routes/(user)/people/+page.svelte +++ b/web/src/routes/(user)/people/+page.svelte @@ -357,7 +357,7 @@ {/if} - + {#if countTotalPeople > 0} (selectHidden = !selectHidden)}> diff --git a/web/src/routes/(user)/people/+page.ts b/web/src/routes/(user)/people/+page.ts index 0d82a1fa48..0a0852b960 100644 --- a/web/src/routes/(user)/people/+page.ts +++ b/web/src/routes/(user)/people/+page.ts @@ -3,11 +3,10 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate(); + await authenticate(); const { data: people } = await api.personApi.getAllPeople({ withHidden: true }); return { - user, people, meta: { title: 'People', diff --git a/web/src/routes/(user)/people/[personId]/+page.ts b/web/src/routes/(user)/people/[personId]/+page.ts index 71f6f46b31..9b730f239c 100644 --- a/web/src/routes/(user)/people/[personId]/+page.ts +++ b/web/src/routes/(user)/people/[personId]/+page.ts @@ -3,13 +3,12 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { - const user = await authenticate(); + await authenticate(); const { data: person } = await api.personApi.getPerson({ id: params.personId }); const { data: statistics } = await api.personApi.getPersonStatistics({ id: params.personId }); return { - user, person, statistics, meta: { diff --git a/web/src/routes/(user)/photos/+page.svelte b/web/src/routes/(user)/photos/+page.svelte index e74a109b92..913c4d038e 100644 --- a/web/src/routes/(user)/photos/+page.svelte +++ b/web/src/routes/(user)/photos/+page.svelte @@ -20,12 +20,10 @@ import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store'; import { AssetStore } from '$lib/stores/assets.store'; import { openFileUploadDialog } from '$lib/utils/file-uploader'; - import type { PageData } from './$types'; import { assetViewingStore } from '$lib/stores/asset-viewing.store'; import { mdiDotsVertical, mdiPlus } from '@mdi/js'; import UpdatePanel from '$lib/components/shared-components/update-panel.svelte'; - - export let data: PageData; + import { user } from '$lib/stores/user.store'; let { isViewing: showAssetViewer } = assetViewingStore; let handleEscapeKey = false; @@ -52,7 +50,7 @@ {#if $isMultiSelectState} assetInteractionStore.clearMultiselect()} > @@ -80,7 +78,7 @@ {/if} - + - {#if data.user.memoriesEnabled} + {#if $user.memoriesEnabled} {/if} { - const user = await authenticate(); + await authenticate(); return { - user, meta: { title: 'Photos', }, diff --git a/web/src/routes/(user)/search/+page.svelte b/web/src/routes/(user)/search/+page.svelte index c020c20e7a..727d72c151 100644 --- a/web/src/routes/(user)/search/+page.svelte +++ b/web/src/routes/(user)/search/+page.svelte @@ -142,7 +142,7 @@
{#each albums as album (album.id)} - + {/each}
diff --git a/web/src/routes/(user)/search/+page.ts b/web/src/routes/(user)/search/+page.ts index 0bd978efee..1f2cffcbaf 100644 --- a/web/src/routes/(user)/search/+page.ts +++ b/web/src/routes/(user)/search/+page.ts @@ -3,13 +3,12 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async (data) => { - const user = await authenticate(); + await authenticate(); const url = new URL(data.url.href); const term = url.searchParams.get('q') || url.searchParams.get('query') || undefined; const { data: results } = await api.searchApi.search({}, { params: url.searchParams }); return { - user, term, results, meta: { diff --git a/web/src/routes/(user)/share/[key]/+page.svelte b/web/src/routes/(user)/share/[key]/+page.svelte index c8ab740236..6a0f2d64f5 100644 --- a/web/src/routes/(user)/share/[key]/+page.svelte +++ b/web/src/routes/(user)/share/[key]/+page.svelte @@ -8,12 +8,12 @@ import { api, SharedLinkType } from '@api'; import type { PageData } from './$types'; import { handleError } from '$lib/utils/handle-error'; + import { user } from '$lib/stores/user.store'; export let data: PageData; let { sharedLink, passwordRequired, sharedLinkKey: key } = data; let { title, description } = data.meta; - - let isOwned = data.user ? data.user.id === sharedLink?.userId : false; + let isOwned = $user ? $user.id === sharedLink?.userId : false; let password = ''; const handlePasswordSubmit = async () => { @@ -21,7 +21,7 @@ const result = await api.sharedLinkApi.getMySharedLink({ password, key }); passwordRequired = false; sharedLink = result.data; - isOwned = data.user ? data.user.id === sharedLink.userId : false; + isOwned = $user ? $user.id === sharedLink.userId : false; title = (sharedLink.album ? sharedLink.album.albumName : 'Public Share') + ' - Immich'; description = sharedLink.description || `${sharedLink.assets.length} shared photos & videos.`; } catch (error) { diff --git a/web/src/routes/(user)/share/[key]/+page.ts b/web/src/routes/(user)/share/[key]/+page.ts index d23f393ca3..9020e723ba 100644 --- a/web/src/routes/(user)/share/[key]/+page.ts +++ b/web/src/routes/(user)/share/[key]/+page.ts @@ -6,7 +6,7 @@ import type { PageLoad } from './$types'; export const load = (async ({ params }) => { const { key } = params; - const user = await getAuthUser(); + await getAuthUser(); try { const { data: sharedLink } = await api.sharedLinkApi.getMySharedLink({ key }); @@ -15,7 +15,6 @@ export const load = (async ({ params }) => { const assetId = sharedLink.album?.albumThumbnailAssetId || sharedLink.assets[0]?.id; return { - user, sharedLink, meta: { title: sharedLink.album ? sharedLink.album.albumName : 'Public Share', diff --git a/web/src/routes/(user)/sharing/+page.svelte b/web/src/routes/(user)/sharing/+page.svelte index 904901053d..ef9b754107 100644 --- a/web/src/routes/(user)/sharing/+page.svelte +++ b/web/src/routes/(user)/sharing/+page.svelte @@ -39,7 +39,7 @@ }; - +
@@ -96,7 +96,7 @@
{#each data.sharedAlbums as album (album.id)} - + {/each}
diff --git a/web/src/routes/(user)/sharing/+page.ts b/web/src/routes/(user)/sharing/+page.ts index 76932342c2..5f0291ed33 100644 --- a/web/src/routes/(user)/sharing/+page.ts +++ b/web/src/routes/(user)/sharing/+page.ts @@ -3,12 +3,11 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate(); + await authenticate(); const { data: sharedAlbums } = await api.albumApi.getAllAlbums({ shared: true }); const { data: partners } = await api.partnerApi.getPartners({ direction: 'shared-with' }); return { - user, sharedAlbums, partners, meta: { diff --git a/web/src/routes/(user)/sharing/sharedlinks/+page.ts b/web/src/routes/(user)/sharing/sharedlinks/+page.ts index 61865785c4..dd07ff42f9 100644 --- a/web/src/routes/(user)/sharing/sharedlinks/+page.ts +++ b/web/src/routes/(user)/sharing/sharedlinks/+page.ts @@ -2,9 +2,8 @@ import { authenticate } from '$lib/utils/auth'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate(); + await authenticate(); return { - user, meta: { title: 'Shared Links', }, diff --git a/web/src/routes/(user)/trash/+page.svelte b/web/src/routes/(user)/trash/+page.svelte index 848f2f76ea..671154ea27 100644 --- a/web/src/routes/(user)/trash/+page.svelte +++ b/web/src/routes/(user)/trash/+page.svelte @@ -71,7 +71,7 @@ {/if} {#if $featureFlags.loaded && $featureFlags.trash} - +
diff --git a/web/src/routes/(user)/trash/+page.ts b/web/src/routes/(user)/trash/+page.ts index cc0e39f16b..ea0647c286 100644 --- a/web/src/routes/(user)/trash/+page.ts +++ b/web/src/routes/(user)/trash/+page.ts @@ -2,9 +2,8 @@ import { authenticate } from '$lib/utils/auth'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate(); + await authenticate(); return { - user, meta: { title: 'Trash', }, diff --git a/web/src/routes/(user)/user-settings/+page.svelte b/web/src/routes/(user)/user-settings/+page.svelte index 32d95a18dd..616b22203d 100644 --- a/web/src/routes/(user)/user-settings/+page.svelte +++ b/web/src/routes/(user)/user-settings/+page.svelte @@ -6,10 +6,10 @@ export let data: PageData; - +
- +
diff --git a/web/src/routes/(user)/user-settings/+page.ts b/web/src/routes/(user)/user-settings/+page.ts index 93aa5ddeeb..cc288cf4ac 100644 --- a/web/src/routes/(user)/user-settings/+page.ts +++ b/web/src/routes/(user)/user-settings/+page.ts @@ -3,13 +3,12 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate(); + await authenticate(); const { data: keys } = await api.keyApi.getApiKeys(); const { data: devices } = await api.authenticationApi.getAuthDevices(); return { - user, keys, devices, meta: { diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index 928164bb67..ea0df75588 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -7,7 +7,6 @@ import UploadPanel from '$lib/components/shared-components/upload-panel.svelte'; import NotificationList from '$lib/components/shared-components/notification/notification-list.svelte'; import VersionAnnouncementBox from '$lib/components/shared-components/version-announcement-box.svelte'; - import type { LayoutData } from './$types'; import { fileUploadHandler } from '$lib/utils/file-uploader'; import UploadCover from '$lib/components/shared-components/drag-and-drop-upload-overlay.svelte'; import FullscreenContainer from '$lib/components/shared-components/fullscreen-container.svelte'; @@ -19,9 +18,9 @@ import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store'; import { api } from '@api'; import { closeWebsocketConnection, openWebsocketConnection } from '$lib/stores/websocket'; + import { user } from '$lib/stores/user.store'; let showNavigationLoadingBar = false; - export let data: LayoutData; let albumId: string | undefined; const isSharedLinkRoute = (route: string | null) => route?.startsWith('/(user)/share/[key]'); @@ -122,7 +121,7 @@ -{#if data.user?.isAdmin} +{#if $user?.isAdmin} {/if} diff --git a/web/src/routes/+layout.ts b/web/src/routes/+layout.ts index 77d19fc9a0..ab0a19f1c2 100644 --- a/web/src/routes/+layout.ts +++ b/web/src/routes/+layout.ts @@ -1,29 +1,10 @@ -import { api } from '@api'; import type { LayoutLoad } from './$types'; -import { getSavedUser, setUser } from '$lib/stores/user.store'; - -const getUser = async () => { - try { - const { data: user } = await api.userApi.getMyUserInfo(); - return user; - } catch { - return null; - } -}; export const ssr = false; export const csr = true; export const load = (async () => { - const savedUser = getSavedUser(); - const user = savedUser || (await getUser()); - - if (!savedUser) { - setUser(user); - } - return { - user, meta: { title: 'Immich', }, diff --git a/web/src/routes/admin/jobs-status/+page.svelte b/web/src/routes/admin/jobs-status/+page.svelte index 9768cb4039..839b5399f3 100644 --- a/web/src/routes/admin/jobs-status/+page.svelte +++ b/web/src/routes/admin/jobs-status/+page.svelte @@ -30,7 +30,7 @@ }); - +
diff --git a/web/src/routes/admin/jobs-status/+page.ts b/web/src/routes/admin/jobs-status/+page.ts index b6face823c..342d3fb8e5 100644 --- a/web/src/routes/admin/jobs-status/+page.ts +++ b/web/src/routes/admin/jobs-status/+page.ts @@ -3,12 +3,11 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate({ admin: true }); + await authenticate({ admin: true }); const { data: jobs } = await api.jobApi.getAllJobsStatus(); return { - user, jobs, meta: { title: 'Job Status', diff --git a/web/src/routes/admin/repair/+page.svelte b/web/src/routes/admin/repair/+page.svelte index deb5b013e9..291c39182d 100644 --- a/web/src/routes/admin/repair/+page.svelte +++ b/web/src/routes/admin/repair/+page.svelte @@ -170,7 +170,7 @@ }; - +
handleRepair()} disabled={matches.length === 0 || repairing}> diff --git a/web/src/routes/admin/repair/+page.ts b/web/src/routes/admin/repair/+page.ts index 9ad200116d..8f10f1301c 100644 --- a/web/src/routes/admin/repair/+page.ts +++ b/web/src/routes/admin/repair/+page.ts @@ -3,13 +3,12 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate({ admin: true }); + await authenticate({ admin: true }); const { data: { orphans, extras }, } = await api.auditApi.getAuditFiles(); return { - user, orphans, extras, meta: { diff --git a/web/src/routes/admin/server-status/+page.svelte b/web/src/routes/admin/server-status/+page.svelte index ea8344723d..3a1575fac7 100644 --- a/web/src/routes/admin/server-status/+page.svelte +++ b/web/src/routes/admin/server-status/+page.svelte @@ -21,7 +21,7 @@ }); - +
diff --git a/web/src/routes/admin/server-status/+page.ts b/web/src/routes/admin/server-status/+page.ts index 73d0ab2295..191f2ee13f 100644 --- a/web/src/routes/admin/server-status/+page.ts +++ b/web/src/routes/admin/server-status/+page.ts @@ -3,11 +3,10 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate({ admin: true }); + await authenticate({ admin: true }); const { data: stats } = await api.serverInfoApi.getServerStatistics(); return { - user, stats, meta: { title: 'Server Stats', diff --git a/web/src/routes/admin/system-settings/+page.svelte b/web/src/routes/admin/system-settings/+page.svelte index 8dd4954b0c..5a95b0b920 100644 --- a/web/src/routes/admin/system-settings/+page.svelte +++ b/web/src/routes/admin/system-settings/+page.svelte @@ -44,7 +44,7 @@
{/if} - +
copyToClipboard(JSON.stringify(configs, null, 2))}>
@@ -95,11 +95,7 @@ subtitle="Manage the folder structure and file name of the upload asset" isOpen={$page.url.searchParams.get('open') === 'storage-template'} > - + diff --git a/web/src/routes/admin/system-settings/+page.ts b/web/src/routes/admin/system-settings/+page.ts index fa635ae82d..d86b4c3688 100644 --- a/web/src/routes/admin/system-settings/+page.ts +++ b/web/src/routes/admin/system-settings/+page.ts @@ -3,11 +3,10 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate({ admin: true }); + await authenticate({ admin: true }); const { data: configs } = await api.systemConfigApi.getConfig(); return { - user, configs, meta: { title: 'System Settings', diff --git a/web/src/routes/admin/user-management/+page.svelte b/web/src/routes/admin/user-management/+page.svelte index ee266289aa..2545bb25a8 100644 --- a/web/src/routes/admin/user-management/+page.svelte +++ b/web/src/routes/admin/user-management/+page.svelte @@ -13,6 +13,7 @@ import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte'; import type { PageData } from './$types'; import { mdiCheck, mdiClose, mdiDeleteRestore, mdiPencilOutline, mdiTrashCanOutline } from '@mdi/js'; + import { user } from '$lib/stores/user.store'; export let data: PageData; @@ -104,7 +105,7 @@ }; - +
{#if shouldShowCreateUserForm} @@ -117,7 +118,7 @@ (shouldShowEditUserForm = false)}> @@ -175,21 +176,21 @@ {#if allUsers} - {#each allUsers as user, i} + {#each allUsers as immichUser, i} - {user.email} - {user.name} + {immichUser.email} + {immichUser.name}
- {#if user.externalPath} + {#if immichUser.externalPath} {:else} @@ -197,27 +198,27 @@
- {#if !isDeleted(user)} + {#if !isDeleted(immichUser)} - {#if user.id !== data.user.id} + {#if immichUser.id !== $user.id} {/if} {/if} - {#if isDeleted(user)} + {#if isDeleted(immichUser)} diff --git a/web/src/routes/admin/user-management/+page.ts b/web/src/routes/admin/user-management/+page.ts index 566a307530..d6be13addf 100644 --- a/web/src/routes/admin/user-management/+page.ts +++ b/web/src/routes/admin/user-management/+page.ts @@ -3,11 +3,10 @@ import { api } from '@api'; import type { PageLoad } from './$types'; export const load = (async () => { - const user = await authenticate({ admin: true }); + await authenticate({ admin: true }); const { data: allUsers } = await api.userApi.getAllUsers({ isAll: false }); return { - user, allUsers, meta: { title: 'User Management', diff --git a/web/src/routes/auth/change-password/+page.svelte b/web/src/routes/auth/change-password/+page.svelte index a4d0141d97..08446c8923 100644 --- a/web/src/routes/auth/change-password/+page.svelte +++ b/web/src/routes/auth/change-password/+page.svelte @@ -3,6 +3,7 @@ import ChangePasswordForm from '$lib/components/forms/change-password-form.svelte'; import FullscreenContainer from '$lib/components/shared-components/fullscreen-container.svelte'; import { AppRoute } from '$lib/constants'; + import { user } from '$lib/stores/user.store'; import type { PageData } from './$types'; export let data: PageData; @@ -16,12 +17,12 @@

- Hi {data.user.name} ({data.user.email}), + Hi {$user.name} ({$user.email}),

This is either the first time you are signing into the system or a request has been made to change your password. Please enter the new password below.

- +
diff --git a/web/src/routes/auth/change-password/+page.ts b/web/src/routes/auth/change-password/+page.ts index 0f391a5ad6..838ceeac34 100644 --- a/web/src/routes/auth/change-password/+page.ts +++ b/web/src/routes/auth/change-password/+page.ts @@ -2,15 +2,15 @@ import { AppRoute } from '$lib/constants'; import { authenticate } from '$lib/utils/auth'; import { redirect } from '@sveltejs/kit'; import type { PageLoad } from './$types'; +import { getSavedUser } from '$lib/stores/user.store'; export const load = (async () => { - const user = await authenticate(); - if (!user.shouldChangePassword) { + await authenticate(); + if (!getSavedUser().shouldChangePassword) { throw redirect(302, AppRoute.PHOTOS); } return { - user, meta: { title: 'Change Password', },