2023-07-01 06:50:47 +02:00
|
|
|
import { AppRoute } from '$lib/constants';
|
2022-08-25 06:10:48 +02:00
|
|
|
import { redirect } from '@sveltejs/kit';
|
2023-11-18 05:13:36 +01:00
|
|
|
import { api } from '../api';
|
|
|
|
import { isLoggedIn } from '../lib/utils/auth';
|
|
|
|
import type { PageLoad } from './$types';
|
|
|
|
|
|
|
|
export const ssr = false;
|
|
|
|
export const csr = true;
|
2022-08-25 06:10:48 +02:00
|
|
|
|
2023-11-18 05:13:36 +01:00
|
|
|
export const load = (async () => {
|
|
|
|
const authenticated = await isLoggedIn();
|
|
|
|
if (authenticated) {
|
2023-07-01 06:50:47 +02:00
|
|
|
throw redirect(302, AppRoute.PHOTOS);
|
|
|
|
}
|
2023-01-11 04:36:50 +01:00
|
|
|
|
2023-10-11 04:37:13 +02:00
|
|
|
const { data } = await api.serverInfoApi.getServerConfig();
|
|
|
|
if (data.isInitialized) {
|
|
|
|
// Redirect to login page if there exists an admin account (i.e. server is initialized)
|
2023-07-01 06:50:47 +02:00
|
|
|
throw redirect(302, AppRoute.AUTH_LOGIN);
|
|
|
|
}
|
2023-02-15 13:42:41 +01:00
|
|
|
|
2023-07-01 06:50:47 +02:00
|
|
|
return {
|
|
|
|
meta: {
|
|
|
|
title: 'Welcome 🎉',
|
|
|
|
description: 'Immich Web Interface',
|
|
|
|
},
|
|
|
|
};
|
2023-11-18 05:13:36 +01:00
|
|
|
}) satisfies PageLoad;
|