vorgang-via-url #9

Merged
jared merged 6 commits from vorgang-via-url into development 2025-06-19 16:20:41 +02:00
3 changed files with 24 additions and 6 deletions
Showing only changes of commit 28e93fe943 - Show all commits

View File

@@ -8,3 +8,4 @@ import config from '$lib/config';
export const client = new Client(config.minio);
export const BUCKET = 'tatort';
export const TOKENFILENAME = '__perm__';

View File

@@ -1,5 +1,5 @@
import { fail, redirect } from '@sveltejs/kit';
import { BUCKET, client } from '$lib/minio';
import { BUCKET, client, TOKENFILENAME } from '$lib/minio';
import { checkIfExactDirectoryExists } from './s3ClientService';
/**
@@ -38,7 +38,7 @@ export const redirectIfVorgangExists = async (request: Request) => {
});
}
redirect(303, `/list/${caseId}`);
redirect(303, `/list/${caseId}?token=${caseToken}`);
};
export const getVorgangByCaseId = ({ params }) => {
@@ -76,14 +76,13 @@ export const getVorgangByCaseId = ({ params }) => {
});
};
const hasValidToken = async (caseId: string, caseToken: string) => {
const tokenFileName = '__perm__';
const objPath = `${caseId}/${tokenFileName}`;
export const hasValidToken = async (caseId: string, caseToken: string) => {
const objPath = `${caseId}/${TOKENFILENAME}`;
try {
if (!caseToken) return false;
const res = await client.getObject('tatort', objPath);
const res = await client.getObject(BUCKET, objPath);
const savedToken = await new Response(res).text();

View File

@@ -0,0 +1,18 @@
import { hasValidToken } from '$lib/server/vorgangService';
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from '../../view/$types';
export const load: PageServerLoad = ({params, url}) => {
const caseID = params.vorgang;
const token = url.searchParams.get('token');
let isTokenValid
if (typeof token === 'string' && caseID) {
isTokenValid = hasValidToken(caseID, token);
}
if(!isTokenValid) {
redirect(303, '/anmeldung');
}
};