added admin dashboard

This commit is contained in:
2026-04-20 12:48:58 +02:00
parent 6145775922
commit d3f740cfa9
56 changed files with 4438 additions and 669 deletions
+19
View File
@@ -0,0 +1,19 @@
import type { Actions } from './$types';
import { fail, redirect } from '@sveltejs/kit';
import { createSession, verifyCredentials } from '$lib/server/auth';
export const actions: Actions = {
default: async ({ request, cookies }) => {
const form = await request.formData();
const username = String(form.get('username') ?? '').trim();
const password = String(form.get('password') ?? '');
if (!username || !password) {
return fail(400, { error: 'Compila username e password.', username });
}
if (!verifyCredentials(username, password)) {
return fail(401, { error: 'Credenziali non valide.', username });
}
createSession(username, cookies);
throw redirect(303, '/admin');
}
};