(null)
async function verify(token: string) {
@@ -34,8 +42,17 @@ export function VerifyForm() {
const body = await res.json().catch(() => null)
throw new Error(body?.detail?.message ?? "Lenken er ugyldig eller utløpt.")
}
- const user = await res.json()
- setEmail(user.email)
+ const result: LoginResult = await res.json()
+ if (result.status === "2fa_required") {
+ setTwoFactorMethod(result.two_factor_method ?? "totp")
+ setStatus("2fa-verify")
+ return
+ }
+ if (result.status === "2fa_setup_required") {
+ setStatus("2fa-setup")
+ return
+ }
+ setEmail(result.user?.email ?? null)
setStatus("success")
// Kort pause så brukeren rekker å se bekreftelsen før vi går videre.
setTimeout(() => router.replace("/dashboard"), 900)
@@ -45,6 +62,10 @@ export function VerifyForm() {
}
}
+ function handleTwoFactorSuccess() {
+ router.replace("/dashboard")
+ }
+
useEffect(() => {
if (urlToken) void verify(urlToken)
// Kjør kun ved mount / når URL-tokenet faktisk endres.
@@ -57,6 +78,26 @@ export function VerifyForm() {
void verify(manualToken.trim())
}
+ if (status === "2fa-verify") {
+ return (
+
+ setStatus("manual")}
+ />
+
+ )
+ }
+
+ if (status === "2fa-setup") {
+ return (
+
+
+
+ )
+ }
+
if (status === "checking" || status === "verifying") {
return (
diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs
index 0e41a12..67c775c 100644
--- a/frontend/next.config.mjs
+++ b/frontend/next.config.mjs
@@ -14,6 +14,7 @@ const nextConfig = {
{ source: "/auth/:path*", destination: `${API_ORIGIN}/auth/:path*` },
{ source: "/orgs/:path*", destination: `${API_ORIGIN}/orgs/:path*` },
{ source: "/public/:path*", destination: `${API_ORIGIN}/public/:path*` },
+ { source: "/superadmin/:path*", destination: `${API_ORIGIN}/superadmin/:path*` },
{ source: "/health", destination: `${API_ORIGIN}/health` },
]
},