Release 0.7.3
This commit is contained in:
1 parent
d5b1c58ba2
commit
21c0de7dd9
31 files changed
+1582
-15
No files matched your search
@@ -8,13 +8,26 @@ import {
|
||||
validEmail
|
||||
} from '#lib/server/auth.js';
|
||||
|
||||
export const load: PageServerLoad = ({ locals }) => {
|
||||
function safeReturnTo(value: string | null): string {
|
||||
if (!value || value.length > 4000) return '/fundus';
|
||||
try {
|
||||
const target = new URL(value, 'http://sendewerk.local');
|
||||
if (target.origin === 'http://sendewerk.local' && target.pathname === '/oauth/authorize') {
|
||||
return `${target.pathname}${target.search}`;
|
||||
}
|
||||
} catch {
|
||||
// Fall back to the normal authenticated landing page.
|
||||
}
|
||||
return '/fundus';
|
||||
}
|
||||
|
||||
export const load: PageServerLoad = ({ locals, url }) => {
|
||||
if (!hasUsers()) redirect(303, '/setup');
|
||||
if (locals.user) redirect(303, '/fundus');
|
||||
if (locals.user) redirect(303, safeReturnTo(url.searchParams.get('returnTo')));
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
default: async ({ request, cookies, getClientAddress }) => {
|
||||
default: async ({ request, cookies, getClientAddress, url }) => {
|
||||
const data = await request.formData();
|
||||
const email = String(data.get('email') || '').trim();
|
||||
const password = String(data.get('password') || '');
|
||||
@@ -31,6 +44,6 @@ export const actions = {
|
||||
const user = await authenticate(email, password);
|
||||
if (!user) return fail(400, { email, error: 'E-Mail oder Passwort ist nicht korrekt.' });
|
||||
createSession(user.id, cookies);
|
||||
redirect(303, '/fundus');
|
||||
redirect(303, safeReturnTo(url.searchParams.get('returnTo')));
|
||||
}
|
||||
} satisfies Actions;
|
||||
Reference in new issue
Block a user