account: nach der Anmeldung direkt ins Portal #422

Merged
patrick merged 1 commits from feat/login-zum-portal into main 2026-10-28 23:49:57 +01:00
2 changed files with 16 additions and 3 deletions

No files matched your search

+11 -3
View File
@@ -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<string | null>(null);
const [submitting, setSubmitting] = useState(false);
useEffect(() => {
fetchMe().then(goToPortal).catch(() => {});
}, []);
async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
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
+5
View File
@@ -39,6 +39,11 @@ export default function ProfilePage() {
return (
<main style={{ maxWidth: 480, margin: "40px auto", padding: "0 16px" }}>
<h1>Mein Profil</h1>
{process.env.NEXT_PUBLIC_PORTAL_URL && (
<p>
<a href={process.env.NEXT_PUBLIC_PORTAL_URL}>Zum Portal</a>
</p>
)}
{me && (
<section aria-labelledby="stammdaten-heading">
<h2 id="stammdaten-heading">Stammdaten</h2>