user setup now only triggers if no user is present not on every startup

This commit is contained in:
Patrick 2025-07-27 06:40:08 +02:00
parent 214bbdfb4d
commit 1ef75efcd8
1 changed files with 14 additions and 9 deletions

View File

@ -4,18 +4,12 @@ import { error, redirect } from "@sveltejs/kit";
import { env } from "$env/dynamic/private"
import SessionStore from "$lib/server/session_store"
import { init_db, close_db, create_user } from "$lib/server/database";
import { init_db, close_db, create_user, do_users_exist } from "$lib/server/database";
import Logs from "$lib/server/log";
let local_setup = {
user_setup: (username: string, password: string) => {
Logs.user.info("Creating first user")
create_user({name: "name", gender: "x", address: "home", username: username, password: password });
local_setup.user_setup = () => {}
}
let local_setup: {user_setup: (() => void) | ((username: string, password: string) => void) }= {
user_setup: () => {}
}
async function init() {
@ -33,6 +27,17 @@ async function init() {
await init_db();
if (!do_users_exist()) {
local_setup.user_setup = (username: string, password: string) => {
Logs.user.info("Creating first user")
create_user({name: "name", gender: "x", address: "home", username: username, password: password });
local_setup.user_setup = () => {}
}
}
Logs.process.info("Initializing of server complete")
}