diff --git a/web/account/app/login/page.tsx b/web/account/app/login/page.tsx index bb540a19..508fc1bf 100644 --- a/web/account/app/login/page.tsx +++ b/web/account/app/login/page.tsx @@ -1,8 +1,12 @@ "use client"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { TextField, useToast } from "@nexarch/shl"; -import { ApiError, login } from "../../lib/api"; +import { ApiError, fetchMe, login } from "../../lib/api"; + +function goToPortal(): void { + window.location.href = process.env.NEXT_PUBLIC_PORTAL_URL || "/profile"; +} export default function LoginPage() { const { push } = useToast(); @@ -13,6 +17,10 @@ export default function LoginPage() { const [error, setError] = useState(null); const [submitting, setSubmitting] = useState(false); + useEffect(() => { + fetchMe().then(goToPortal).catch(() => {}); + }, []); + async function onSubmit(event: React.FormEvent) { event.preventDefault(); setError(null); @@ -20,7 +28,7 @@ export default function LoginPage() { try { await login(email, password, needsSecondFactor ? totpCode : undefined); push("Anmeldung erfolgreich.", "success"); - window.location.href = "/profile"; + goToPortal(); } catch (err) { if (err instanceof ApiError) { // Akzeptanzkriterium 3 / Pruefung 1: nur die generische, vom Backend diff --git a/web/account/app/profile/page.tsx b/web/account/app/profile/page.tsx index 44d235d0..5b94d1e7 100644 --- a/web/account/app/profile/page.tsx +++ b/web/account/app/profile/page.tsx @@ -39,6 +39,11 @@ export default function ProfilePage() { return (

Mein Profil

+ {process.env.NEXT_PUBLIC_PORTAL_URL && ( +

+ Zum Portal +

+ )} {me && (

Stammdaten