Compare commits
4 Commits
9ddec90214
...
a7eb81151f
| Author | SHA1 | Date | |
|---|---|---|---|
| a7eb81151f | |||
| 8408d63f40 | |||
| f2bde76969 | |||
| 83bcaca918 |
@@ -1,12 +1,9 @@
|
|||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
import jsSHA from 'jssha';
|
import jsSHA from 'jssha';
|
||||||
import Database from 'better-sqlite3';
|
|
||||||
import process from 'process';
|
import process from 'process';
|
||||||
|
import db from '$lib/server/dbService';
|
||||||
|
|
||||||
import config from '$lib/config';
|
import config from '$lib/config';
|
||||||
// import db from '../init/init_db';
|
|
||||||
|
|
||||||
let db = new Database('./src/lib/data/tatort.db');
|
|
||||||
|
|
||||||
const SECRET = config.jwt.secret;
|
const SECRET = config.jwt.secret;
|
||||||
const EXPIRES_IN = config.jwt.expiresIn;
|
const EXPIRES_IN = config.jwt.expiresIn;
|
||||||
|
|||||||
3
src/lib/server/dbService.ts
Normal file
3
src/lib/server/dbService.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import Database from 'better-sqlite3';
|
||||||
|
|
||||||
|
export const db = new Database('./src/lib/data/tatort.db');
|
||||||
@@ -2,8 +2,7 @@ import { fail } from '@sveltejs/kit';
|
|||||||
import { BUCKET, client, CONFIGFILENAME, TOKENFILENAME } from '$lib/minio';
|
import { BUCKET, client, CONFIGFILENAME, TOKENFILENAME } from '$lib/minio';
|
||||||
import { checkIfExactDirectoryExists, getContentOfTextObject } from './s3ClientService';
|
import { checkIfExactDirectoryExists, getContentOfTextObject } from './s3ClientService';
|
||||||
|
|
||||||
import Database from 'better-sqlite3';
|
import { db } from './dbService';
|
||||||
const db = new Database('./src/lib/data/tatort.db');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Vorgang and corresponend list of tatorte
|
* Get Vorgang and corresponend list of tatorte
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { client } from '$lib/minio';
|
|||||||
import { fail } from '@sveltejs/kit';
|
import { fail } from '@sveltejs/kit';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import Database from 'better-sqlite3';
|
import { db } from '$lib/server/dbService';
|
||||||
|
|
||||||
const isRequiredFieldValid = (value: unknown) => {
|
const isRequiredFieldValid = (value: unknown) => {
|
||||||
if (value == null) return false;
|
if (value == null) return false;
|
||||||
@@ -25,7 +25,6 @@ export const actions = {
|
|||||||
|
|
||||||
// store case in database
|
// store case in database
|
||||||
|
|
||||||
let db = new Database('./src/lib/data/tatort.db');
|
|
||||||
let token = uuidv4();
|
let token = uuidv4();
|
||||||
let insert_stmt = `INSERT INTO cases (token, name, pw) VALUES (?, ?, ?)`;
|
let insert_stmt = `INSERT INTO cases (token, name, pw) VALUES (?, ?, ?)`;
|
||||||
const stmt = db.prepare(insert_stmt);
|
const stmt = db.prepare(insert_stmt);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export const load: PageServerLoad = async ({ params, url, locals }) => {
|
|||||||
|
|
||||||
const isVorgangValid = vorgangExists(caseId);
|
const isVorgangValid = vorgangExists(caseId);
|
||||||
const isTokenValid = tokenValid(caseId, caseToken);
|
const isTokenValid = tokenValid(caseId, caseToken);
|
||||||
console.log(`--- is valid: ${isTokenValid}`);
|
|
||||||
|
|
||||||
if (!isVorgangValid || !isTokenValid) throw redirect(303, `/anmeldung`);
|
if (!isVorgangValid || !isTokenValid) throw redirect(303, `/anmeldung?vorgang=${caseId}`);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -129,11 +129,24 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setClipboard(text) {
|
||||||
|
const type = "text/plain";
|
||||||
|
const clipboardItemData = {
|
||||||
|
[type]: text,
|
||||||
|
};
|
||||||
|
const clipboardItem = new ClipboardItem(clipboardItemData);
|
||||||
|
await navigator.clipboard.write([clipboardItem]);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="-z-10 bg-white">
|
<div class="-z-10 bg-white">
|
||||||
<div class="flex flex-col items-center justify-center w-full">
|
<div class="flex flex-col items-center justify-center w-full">
|
||||||
<h1 class="text-xl">Vorgang {vorg.name}</h1>
|
<h1 class="text-xl">Vorgang {vorg.name}</h1>
|
||||||
|
{#if data?.user?.admin}
|
||||||
|
Zugangspasswort: {vorg.pw}
|
||||||
|
<Button on:click={() => setClipboard($page.url.toString().split('?')[0])}>Copy Link</Button>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="mx-auto flex justify-center max-w-7xl h-full">
|
<div class="mx-auto flex justify-center max-w-7xl h-full">
|
||||||
<ul class="divide-y divide-gray-100">
|
<ul class="divide-y divide-gray-100">
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
export let form;
|
export let form;
|
||||||
|
|
||||||
export let open = false;
|
export let open = false;
|
||||||
|
|
||||||
|
import { page } from '$app/state';
|
||||||
|
const vorgang_token = page.url.searchParams.get('vorgang');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||||
@@ -30,7 +33,7 @@
|
|||||||
name="case-id"
|
name="case-id"
|
||||||
label="Vorgangskennung"
|
label="Vorgangskennung"
|
||||||
type="text"
|
type="text"
|
||||||
value={form?.caseId}
|
value={vorgang_token}
|
||||||
/>
|
/>
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
<BaseInputField
|
<BaseInputField
|
||||||
|
|||||||
Reference in New Issue
Block a user