"use client" import Link from "next/link" import { useEffect } from "react" import { useTheme } from "next-themes" import { Loader2 } from "lucide-react" import { AuthCard } from "@/components/auth/auth-card" import { AuthConnectButton } from "@/components/auth/auth-connect-button" import { authentikRecoveryFlowUrl, resolveAuthentikTheme, } from "@/lib/auth/authentik-user-url" import { getAuthentikEnrollmentUrl, getForgotPasswordUrl } from "@/lib/auth/oidc-config" import { useClientThemeStore } from "@/lib/stores/client-theme-store" import { useNativeRuntime } from "@/lib/platform" type LoginPageContentProps = { returnTo?: string error?: string | null } export function LoginPageContent({ returnTo = "/mail/inbox", error = null, }: LoginPageContentProps) { const native = useNativeRuntime() const themeMode = useClientThemeStore((s) => s.themeMode) const { resolvedTheme } = useTheme() const authentikTheme = resolveAuthentikTheme(themeMode, resolvedTheme) const signupHref = native ? `/signup?returnTo=${encodeURIComponent(returnTo)}` : getAuthentikEnrollmentUrl() const forgotPasswordHref = native ? `/forgot-password?returnTo=${encodeURIComponent(returnTo)}` : (authentikRecoveryFlowUrl(authentikTheme) ?? getForgotPasswordUrl()) const oidcHref = `/api/auth/login?returnTo=${encodeURIComponent(returnTo)}` const decodedError = error ? decodeURIComponent(error) : null useEffect(() => { if (!error) { window.location.replace(oidcHref) } }, [error, oidcHref]) const footer = (

Pas encore de compte ?{" "} {native ? ( Créer un compte ) : ( Créer un compte )}

{native ? ( Mot de passe oublié ? ) : ( Mot de passe oublié ? )}

) if (error) { return ( Réessayer ) } return (
Redirection…
) }