Files
marktvogt.de/web/src/lib/auth/guard.ts
vikingowl 2e6acceb33 feat: add admin panel, market submission form, and legal updates
- Admin layout with auth guard at /admin
- Admin market list with status filter tabs (pending/approved/rejected)
- Admin market detail/review with approve/reject actions
- Admin market create and edit forms with shared MarketForm component
- Anonymous market submission form at /markt/einreichen with Turnstile
- Optional latitude/longitude fields on submission form
- Admin and submission types added to API types
- requireAdmin guard for role-based frontend access
- Header/mobile nav updated with admin and submission links
- Auth layout redirect removed to re-enable login flow
- Login form action renamed to fix named actions conflict
- Impressum updated with user-submitted content section
- Datenschutz updated with submission form and Turnstile sections
2026-02-27 11:04:31 +01:00

18 lines
544 B
TypeScript

import { error, redirect } from '@sveltejs/kit';
import type { ServerLoadEvent } from '@sveltejs/kit';
export function requireAuth(event: ServerLoadEvent): void {
if (!event.locals.user) {
redirect(302, `/auth/anmelden?redirect=${encodeURIComponent(event.url.pathname)}`);
}
}
export function requireAdmin(event: ServerLoadEvent): void {
if (!event.locals.user) {
redirect(302, `/auth/anmelden?redirect=${encodeURIComponent(event.url.pathname)}`);
}
if (event.locals.user.role !== 'admin') {
error(403, 'Zugriff verweigert');
}
}