This commit is contained in:
Fran Jurmanović
2025-02-08 15:43:57 +01:00
parent face750b7d
commit e2fa9d2f7e
37 changed files with 5183 additions and 128 deletions

View File

@@ -0,0 +1,18 @@
import { checkAuth, login } from '$api/authService';
import { authStore } from '$stores/authStore';
import type { Actions } from './$types';
import { redirect } from '@sveltejs/kit';
export const actions = {
login: async ({ request }) => {
const formData = await 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);
if (isAuth) redirect(303, '/dashboard');
}
} satisfies Actions;