Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
23 lines
742 B
TypeScript
23 lines
742 B
TypeScript
import { vorgangPINValidation, vorgangExists } from '$lib/server/vorgangService';
|
|
import { redirect } from '@sveltejs/kit';
|
|
import type { LayoutServerLoad } from './$types';
|
|
import { ROUTE_NAMES } from '..';
|
|
|
|
export const load: LayoutServerLoad = async ({ params, cookies, locals }) => {
|
|
if (locals.user) {
|
|
return {
|
|
user: locals.user
|
|
};
|
|
}
|
|
|
|
const vorgangToken = params.vorgang ?? '';
|
|
const COOKIE_NAME = `token-${vorgangToken}`;
|
|
const vorgangPIN = cookies.get(COOKIE_NAME) ?? '';
|
|
|
|
const isVorgangValid = vorgangExists(vorgangToken);
|
|
const isVorgangPINValid = vorgangPINValidation(vorgangToken, vorgangPIN);
|
|
|
|
if (!isVorgangValid || !isVorgangPINValid)
|
|
throw redirect(303, ROUTE_NAMES.ANMELDUNG_VORGANG_PARAM(vorgangToken));
|
|
};
|