aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/login/+page.server.js
blob: 7b70d944a4c3ce80ba08dcf218ce9b1d95e66ead (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { post } from '$lib/utils';
import cookie from 'cookie';

let maxAge = 30 * 24 * 60 * 60;

export async function POST({ request }) {
	let body = await post('/login', await request.json());

	let expires = new Date();
	expires.setSeconds(expires.getSeconds() + maxAge);

	throw new Error("@migration task: Migrate this return statement (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292699)");
	return {
		body,
		headers: {
			'set-cookie': cookie.serialize('token', body.token, {
				httpOnly: true,
				maxAge,
				sameSite: 'lax',
				path: '/',
				expires
			})
		}
	};
}