parent
c207da0462
commit
2140aaf2f8
|
|
@ -35,4 +35,3 @@ pdfgen/*
|
||||||
documents/*
|
documents/*
|
||||||
user-data/*
|
user-data/*
|
||||||
tmp-user-data/*
|
tmp-user-data/*
|
||||||
logs/*
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
import type { Handle } from "@sveltejs/kit";
|
import type { Handle } from "@sveltejs/kit";
|
||||||
import { error, redirect } from "@sveltejs/kit";
|
import { error, redirect } from "@sveltejs/kit";
|
||||||
import { base } from "$app/paths";
|
|
||||||
|
|
||||||
import SessionStore from "$lib/server/session_store"
|
import SessionStore from "$lib/server/session_store"
|
||||||
import { init_db, close_db } from "$lib/server/database";
|
import { init_db, close_db, get_user } from "$lib/server/database";
|
||||||
|
|
||||||
import Logs from "$lib/server/log";
|
import Logs from "$lib/server/log";
|
||||||
|
|
||||||
|
|
@ -57,6 +56,7 @@ export let handle: Handle = async function ({ event, resolve }) {
|
||||||
"Referrer-Policy": "strict-origin-when-cross-origin"
|
"Referrer-Policy": "strict-origin-when-cross-origin"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log(event.url.href)
|
||||||
if (event.route.id == null) {
|
if (event.route.id == null) {
|
||||||
Logs.route.info(`Tried to access a route which does not exist: ${event.url.href}`)
|
Logs.route.info(`Tried to access a route which does not exist: ${event.url.href}`)
|
||||||
return error(404, "This page does not exist.");
|
return error(404, "This page does not exist.");
|
||||||
|
|
@ -78,7 +78,7 @@ export let handle: Handle = async function ({ event, resolve }) {
|
||||||
return await resolve(event);
|
return await resolve(event);
|
||||||
} else {
|
} else {
|
||||||
event.url.searchParams.set("redirect", event.route.id);
|
event.url.searchParams.set("redirect", event.route.id);
|
||||||
return redirect(302, `${base}/login?${event.url.searchParams}`);
|
return redirect(302, `/login?${event.url.searchParams}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { base } from "$app/paths";
|
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -8,14 +6,14 @@
|
||||||
<div class={classlist}>
|
<div class={classlist}>
|
||||||
<h1>Navigation</h1>
|
<h1>Navigation</h1>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="{base}/">Stundenliste</a></li>
|
<li><a href="/">Stundenliste</a></li>
|
||||||
<li><a href="{base}/schaetzung">Stundenschätzung</a></li>
|
<li><a href="/schaetzung">Stundenschätzung</a></li>
|
||||||
<li><a href="{base}/dokumente">Dokumente</a></li>
|
<li><a href="/dokumente">Dokumente</a></li>
|
||||||
|
|
||||||
<li style="height: 20px"></li>
|
<li style="height: 20px"></li>
|
||||||
<li>Benutzerverwaltung</li>
|
<li>Benutzerverwaltung</li>
|
||||||
<li>
|
<li>
|
||||||
<form method="POST" action="{base}/login?/logout">
|
<form method="POST" action="/login?/logout">
|
||||||
<button type="submit">Logout</button>
|
<button type="submit">Logout</button>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { SQLiteError } from "bun:sqlite";
|
||||||
import type { FileProperties } from "$lib/server/docstore"
|
import type { FileProperties } from "$lib/server/docstore"
|
||||||
import type { RecordEntry, EstimatesEntry } from "$lib/db_types";
|
import type { RecordEntry, EstimatesEntry } from "$lib/db_types";
|
||||||
|
|
||||||
import { fail } from '@sveltejs/kit';
|
import { fail, redirect } from '@sveltejs/kit';
|
||||||
|
|
||||||
import Logs from "$lib/server/log"
|
import Logs from "$lib/server/log"
|
||||||
import { toInt, parseDate, isTimeValidHHMM } from "$lib/util"
|
import { toInt, parseDate, isTimeValidHHMM } from "$lib/util"
|
||||||
|
|
@ -230,6 +230,7 @@ export const actions = {
|
||||||
return fail(500, { })
|
return fail(500, { })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redirect(303, '/');
|
||||||
return { success: true };
|
return { success: true };
|
||||||
},
|
},
|
||||||
remove_entry: async ({ locals, request })=> {
|
remove_entry: async ({ locals, request })=> {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import type { PageServerLoad, Actions } from "./$types";
|
import type { PageServerLoad, Actions } from "./$types";
|
||||||
import { fail, redirect } from "@sveltejs/kit"
|
import { fail, redirect } from "@sveltejs/kit"
|
||||||
import { base } from "$app/paths"
|
|
||||||
|
|
||||||
import { toInt } from "$lib/util"
|
import { toInt } from "$lib/util"
|
||||||
|
|
||||||
|
|
@ -65,7 +64,7 @@ export const actions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
redirect(303, `${base}/dokumente`)
|
redirect(303, "dokumente")
|
||||||
}
|
}
|
||||||
|
|
||||||
} satisfies Actions;
|
} satisfies Actions;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import type { Actions } from "@sveltejs/kit";
|
import type { Actions } from "@sveltejs/kit";
|
||||||
import type { PageServerLoad } from "./$types";
|
import type { PageServerLoad } from "./$types";
|
||||||
import { fail, redirect } from "@sveltejs/kit";
|
import { fail, redirect } from "@sveltejs/kit";
|
||||||
import { base } from "$app/paths"
|
|
||||||
|
|
||||||
import { authorize_password } from "$lib/server/auth";
|
import { authorize_password } from "$lib/server/auth";
|
||||||
import SessionStore from "$lib/server/session_store";
|
import SessionStore from "$lib/server/session_store";
|
||||||
|
|
@ -23,6 +22,8 @@ export const actions = {
|
||||||
if (locals.user != null) {
|
if (locals.user != null) {
|
||||||
redirect(302, redirect_url);
|
redirect(302, redirect_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("logging in");
|
||||||
|
|
||||||
const params = await request.formData();
|
const params = await request.formData();
|
||||||
const username = params.get("username") as string | null;
|
const username = params.get("username") as string | null;
|
||||||
|
|
@ -46,7 +47,7 @@ export const actions = {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
secure: true,
|
secure: true,
|
||||||
sameSite: 'strict',
|
sameSite: 'strict',
|
||||||
path: base
|
path: '/'
|
||||||
})
|
})
|
||||||
|
|
||||||
redirect(302, redirect_url);
|
redirect(302, redirect_url);
|
||||||
|
|
@ -65,8 +66,8 @@ export const actions = {
|
||||||
|
|
||||||
SessionStore.logout_user_session(token);
|
SessionStore.logout_user_session(token);
|
||||||
|
|
||||||
cookies.delete("session_id", { path: base });
|
cookies.delete("session_id", { path: "/" });
|
||||||
|
|
||||||
return redirect(302, `${base}/login`);
|
return redirect(302, "/login");
|
||||||
}
|
}
|
||||||
} satisfies Actions;
|
} satisfies Actions;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form id="form_add_quart" method="POST" action="?/add_quarter" use:enhance></form>
|
<form id="form_add_quart" method="POST" action="?/add_quarter" use:enhance></form>
|
||||||
<form id="form_create_pdf" method="POST" action="{base}/dokumente?/create_estimate" use:enhance></form>
|
<form id="form_create_pdf" method="POST" action="/dokumente?/create_estimate" use:enhance></form>
|
||||||
|
|
||||||
<h1>Stundenschätzung</h1>
|
<h1>Stundenschätzung</h1>
|
||||||
|
|
||||||
|
|
@ -130,7 +130,7 @@
|
||||||
<button type="submit">Download PDF</button>
|
<button type="submit">Download PDF</button>
|
||||||
</form>
|
</form>
|
||||||
{:else}
|
{:else}
|
||||||
<form method="POST" action="{base}/dokumente?/create_estimate" use:enhance>
|
<form method="POST" action="/dokumente?/create_estimate" use:enhance>
|
||||||
<input type="hidden" name="year" value={year} />
|
<input type="hidden" name="year" value={year} />
|
||||||
<input type="hidden" name="quarter" value={quarter} />
|
<input type="hidden" name="quarter" value={quarter} />
|
||||||
<button type="submit">Create PDF</button>
|
<button type="submit">Create PDF</button>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue