rewrite vorgang exist and token validation check to use DB

This commit is contained in:
2025-07-11 10:19:17 +02:00
parent f7245fac90
commit 9ddec90214
2 changed files with 45 additions and 3 deletions

View File

@@ -1,4 +1,9 @@
import { checkIfVorgangExists, hasValidToken } from '$lib/server/vorgangService';
import {
checkIfVorgangExists,
hasValidToken,
tokenValid,
vorgangExists
} from '$lib/server/vorgangService';
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './list/[vorgang]/$types';
@@ -12,8 +17,9 @@ export const load: PageServerLoad = async ({ params, url, locals }) => {
const caseId = params.vorgang;
const caseToken = url.searchParams.get('token');
const isVorgangValid = await checkIfVorgangExists(caseId);
const isTokenValid = await hasValidToken(caseId, caseToken);
const isVorgangValid = vorgangExists(caseId);
const isTokenValid = tokenValid(caseId, caseToken);
console.log(`--- is valid: ${isTokenValid}`);
if (!isVorgangValid || !isTokenValid) throw redirect(303, `/anmeldung`);
};