fix(server): require local admin account (#1070)

This commit is contained in:
Jason Rasmussen
2022-12-09 15:53:11 -05:00
committed by GitHub
parent 3bb103c6b6
commit 14889e7d85
14 changed files with 119 additions and 38 deletions

View File

@@ -0,0 +1,13 @@
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { serverApi } from '@api';
export const load: PageServerLoad = async () => {
const { data } = await serverApi.userApi.getUserCount(true);
if (data.userCount === 0) {
// Admin not registered
throw redirect(302, '/auth/register');
}
return;
};

View File

@@ -3,7 +3,7 @@ import type { PageServerLoad } from './$types';
import { serverApi } from '@api';
export const load: PageServerLoad = async () => {
const { data } = await serverApi.userApi.getUserCount();
const { data } = await serverApi.userApi.getUserCount(true);
if (data.userCount != 0) {
// Admin has been registered, redirect to login
throw redirect(302, '/auth/login');