aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/login/+page.server.js
blob: 28a5d78ab94a2a1943327d994d996c3b5de926c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { invalid, redirect } from '@sveltejs/kit';
import { login } from '$lib/utils';

export const actions = {
	default: async ({ cookies, request }) => {
		let user = Object.fromEntries(await request.formData());
		try {
			await login(user, cookies);
			throw redirect(303, `/${user.username}/dashboard`);
		} catch (e) {
			console.log('OW');
			return invalid(403, { error: 'Login failed' });
		}
	}
};