Skip to content
Snippets Groups Projects
Commit a166558b authored by Aaron Dötsch's avatar Aaron Dötsch
Browse files

changes

parent f87c3b00
No related branches found
No related tags found
No related merge requests found
Showing
with 6997 additions and 7084 deletions
<script lang="ts">
import LL from "$lib/i18n/i18n-svelte";
import { Heading, P } from "flowbite-svelte";
import type { Translation } from "$lib/i18n/i18n-types";
$: paragraphs = Object.keys($LL.PrivacyPolicy.Paragraphs) as (keyof Translation["PrivacyPolicy"]["Paragraphs"])[];
</script>
<Heading tag="h1" customSize="text-4xl font-bold" class="mb-6 text-center">{$LL.PrivacyPolicy.Headline()}</Heading>
{#if $LL.PrivacyPolicy.Disclaimer()}
<P class="mb-6" color="text-red-600 dark:text-red-500" whitespace="preline" weight="extrabold">{$LL.PrivacyPolicy.Disclaimer()}</P>
{/if}
{#each paragraphs as key}
<Heading tag="h3" class="mb-1">{$LL.PrivacyPolicy.Paragraphs[key].Headline()}</Heading>
<P class="mb-6" whitespace="preline">{$LL.PrivacyPolicy.Paragraphs[key].Content()}</P>
{/each}
{#if $LL.PrivacyPolicy.Footer()}
<P class="mt-12 mb-6" whitespace="preline">{$LL.PrivacyPolicy.Footer()}</P>
{/if}
import { redirect, error } from "@sveltejs/kit";
export const actions = {
default: async (request) => {
const data = await request.request.formData();
const username = data.get("username");
const password = data.get("password");
if(typeof username !== "string" || typeof password !== "string") throw error(400, "Invalid form data");
if(isCorrect(username, password)){
// TODO set correct cookie
request.cookies.set("session", "1234", {
path: "/",
sameSite: "strict",
maxAge: 60 * 60 * 24 * 7, // 1 week
});
throw redirect(303, "/admin");
}else{
throw error(401, "Nutzername oder Passwort falsch");
}
},
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function isCorrect(username: string, password: string): boolean {
return true; // TODO: implement
}
<script>
import { FloatingLabelInput, Button, Alert } from "flowbite-svelte";
import { enhance } from "$app/forms";
import { goto } from "$app/navigation";
/** @type {{message:string}|undefined} */
let error;
</script>
<form method="post" use:enhance={()=>{
return ({result})=>{
if(result.type === "success"){
// should never happen, since it always redirects
}else if(result.type === "error"){
error = result.error;
}else if(result.type === "redirect"){
goto(result.location);
}
}
}}>
{#if error}
{#key error}
<Alert color="red" class="mb-5 mt-4 border-t-4" rounded={false} dismissable>{error.message}</Alert>
{/key}
{/if}
<div class="mb-6 mt-4">
<FloatingLabelInput type="text" label="Nutzername" name="username" required />
</div>
<div class="mb-6">
<FloatingLabelInput type="password" label="Passwort" name="password" required />
</div>
<div class="mb-6 flex items-start">
<Button type="submit" color="primary">Anmelden</Button>
</div>
</form>
import type { RequestHandler } from "./$types";
export const GET: RequestHandler = async (request)=>{
// TODO delete cookie
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment