2022-08-24 21:10:48 -07:00
|
|
|
export const prerender = false;
|
2023-02-24 21:42:20 +01:00
|
|
|
|
2022-08-24 21:10:48 -07:00
|
|
|
import { redirect } from '@sveltejs/kit';
|
2023-02-15 13:09:28 -06:00
|
|
|
import type { PageServerLoad } from './$types';
|
2022-08-24 21:10:48 -07:00
|
|
|
|
2023-02-24 21:42:20 +01:00
|
|
|
export const load = (async ({ parent, locals: { api } }) => {
|
2022-08-24 21:10:48 -07:00
|
|
|
const { user } = await parent();
|
|
|
|
|
if (user) {
|
|
|
|
|
throw redirect(302, '/photos');
|
|
|
|
|
}
|
2023-01-10 22:36:50 -05:00
|
|
|
|
2023-05-28 04:52:22 +03:00
|
|
|
const { data } = await api.userApi.getUserCount({ admin: true });
|
2023-02-15 13:09:28 -06:00
|
|
|
|
2023-02-15 13:42:41 +01:00
|
|
|
if (data.userCount > 0) {
|
|
|
|
|
// Redirect to login page if an admin is already registered.
|
|
|
|
|
throw redirect(302, '/auth/login');
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 22:36:50 -05:00
|
|
|
return {
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'Welcome 🎉',
|
|
|
|
|
description: 'Immich Web Interface'
|
|
|
|
|
}
|
|
|
|
|
};
|
2023-02-24 21:42:20 +01:00
|
|
|
}) satisfies PageServerLoad;
|