blob: da8181b4a7970e9246fb765597122851045b8ef2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import { redirect, type RequestHandler } from '@sveltejs/kit';
import { consumeMagicLink, createSession } from '$lib/server/auth';
export const GET: RequestHandler = async ({ url, cookies }) => {
const token = url.searchParams.get('token');
if (!token) throw redirect(303, '/?error=missing-token');
const account = consumeMagicLink(token);
if (!account) throw redirect(303, '/?error=invalid-token');
createSession(cookies, account.id);
throw redirect(303, '/dashboard');
};
|