update state management

This commit is contained in:
Fran Jurmanović
2025-02-08 18:34:06 +01:00
parent 01fc6e9feb
commit 3ad4b95656
10 changed files with 93 additions and 86 deletions

View File

@@ -4,15 +4,15 @@ import type { Actions } from './$types';
import { redirect } from '@sveltejs/kit';
export const actions = {
login: async ({ request }) => {
const formData = await request.formData();
login: async (event) => {
const formData = await event.request.formData();
const username = formData.get('username') as string;
const password = formData.get('password') as string;
if (!username || !password) {
authStore.set({ error: 'Invalid username or password' });
return;
}
const isAuth = await login(username, password);
const isAuth = await login(event, username, password);
if (isAuth) redirect(303, '/dashboard');
}
} satisfies Actions;