account: nach der Anmeldung direkt ins Portal #422
No files matched your search
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user