fixed missing await on (first) user creation

This commit is contained in:
Patrick 2025-09-08 18:53:19 +02:00
parent 8c2039c8a4
commit 15ba32095d
2 changed files with 5 additions and 6 deletions

View File

@ -9,7 +9,7 @@ import { init_db, close_db, create_user, do_users_exist } from "$lib/server/data
import Logs from "$lib/server/log";
let local_setup: {user_setup: (() => void) | ((username: string, password: string) => void) }= {
user_setup: () => {}
user_setup: async () => {}
}
async function init() {
@ -28,12 +28,12 @@ async function init() {
await init_db();
if (!do_users_exist()) {
local_setup.user_setup = (username: string, password: string) => {
local_setup.user_setup = async (username: string, password: string) => {
Logs.user.info("Creating first user")
create_user({name: "name", gender: "x", address: "home", username: username, password: password });
await create_user({name: "name", gender: "x", address: "home", username: username, password: password });
local_setup.user_setup = () => {}
local_setup.user_setup = async () => {}
}
}

View File

@ -33,13 +33,12 @@ export const actions = {
if (locals.user != null) {
redirect(302, _get_redirect(url));
}
const params = await request.formData();
const username = params.get("username") as string | null;
const password = params.get("password") as string | null;
locals.setup.user_setup(username, password)
await locals.setup.user_setup(username, password)
Logs.user.info(`Login attempt for user ${username}`)