feat(login): Verantwortliche landen nach Login auf /dashboard
CI / backend-tests (push) Failing after 1m25s
CI / frontend-build (push) Successful in 24s

Materialverantwortlicher/Leitungsverantwortlicher/Administration werden nach
Login direkt zum neuen Leitungs-Dashboard geleitet statt zur Objektliste.
rollen im AuthContext laden asynchron nach - daher hier direkt /auth/me
abfragen statt auf den Context zu warten.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KC8HYvv6UkCVYheYiTw9DD
This commit is contained in:
2026-09-05 10:39:06 +02:00
co-authored by Claude Sonnet 5
parent 54fc29690a
commit 69d6956d23
+10 -1
View File
@@ -1,7 +1,11 @@
import { useState, type FormEvent } from "react";
import { useNavigate } from "react-router-dom";
import { apiRequest } from "../api/client";
import { useAuth } from "../auth/AuthContext";
import type { Me } from "../api/types";
const VERANTWORTLICH_ROLLEN = ["administration", "materialverantwortlicher", "leitungsverantwortlicher"];
export function LoginPage() {
const { login } = useAuth();
@@ -17,7 +21,12 @@ export function LoginPage() {
setWirdGeladen(true);
try {
await login(username, password);
navigate("/objekte");
// rollen im AuthContext werden erst asynchron nachgeladen (eigener
// useEffect) - für die Landingpage-Entscheidung direkt nach Login
// selbst /auth/me abfragen statt auf den Context zu warten.
const me = await apiRequest<Me>("/auth/me");
const istVerantwortlich = me.rollen.some((r) => VERANTWORTLICH_ROLLEN.includes(r));
navigate(istVerantwortlich ? "/dashboard" : "/objekte");
} catch {
setFehler("Login oder Passwort falsch");
} finally {