34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { AppRoute } from '$lib/constants';
|
|
import { authenticate, requestServerInfo } from '$lib/utils/auth';
|
|
import { getFormatter } from '$lib/utils/i18n';
|
|
import { getUserPreferencesAdmin, getUserSessionsAdmin, getUserStatisticsAdmin, searchUsersAdmin } from '@immich/sdk';
|
|
import { redirect } from '@sveltejs/kit';
|
|
import type { PageLoad } from './$types';
|
|
|
|
export const load = (async ({ params, url }) => {
|
|
await authenticate(url, { admin: true });
|
|
await requestServerInfo();
|
|
const [user] = await searchUsersAdmin({ id: params.id, withDeleted: true }).catch(() => []);
|
|
if (!user) {
|
|
redirect(302, AppRoute.ADMIN_USERS);
|
|
}
|
|
|
|
const [userPreferences, userStatistics, userSessions] = await Promise.all([
|
|
getUserPreferencesAdmin({ id: user.id }),
|
|
getUserStatisticsAdmin({ id: user.id }),
|
|
getUserSessionsAdmin({ id: user.id }),
|
|
]);
|
|
|
|
const $t = await getFormatter();
|
|
|
|
return {
|
|
user,
|
|
userPreferences,
|
|
userStatistics,
|
|
userSessions,
|
|
meta: {
|
|
title: $t('admin.user_details'),
|
|
},
|
|
};
|
|
}) satisfies PageLoad;
|