fix(api,web): corrections auth — gestion d'erreur login, messages explicites
- web: auth/errors (+ tests), LoginPage, client API - api: auth controller/service Refs: #14
This commit is contained in:
@ -2,6 +2,7 @@ import { FormEvent, useEffect, useState } from "react";
|
||||
import { KeyRound, LogIn, ShieldAlert } from "lucide-react";
|
||||
import type { AuthStatusDto } from "@readabook/shared";
|
||||
import { api } from "../api/client";
|
||||
import { loginErrorMessage } from "../auth/errors";
|
||||
import { navigate } from "../router";
|
||||
import { ErrorRibbon, Panel } from "../components/ui";
|
||||
|
||||
@ -38,7 +39,7 @@ export function LoginPage({ onSessionChange }: { onSessionChange: () => Promise<
|
||||
await onSessionChange();
|
||||
navigate("/home");
|
||||
} catch (loginError) {
|
||||
setError(loginError instanceof Error ? loginError.message : "Connexion impossible");
|
||||
setError(loginErrorMessage(loginError));
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,14 +54,20 @@ export function LoginPage({ onSessionChange }: { onSessionChange: () => Promise<
|
||||
<KeyRound size={24} />
|
||||
<h2>Entrer dans le cabinet</h2>
|
||||
<ErrorRibbon message={error} />
|
||||
{status?.initialAdminPasswordIsDefault && (
|
||||
{status?.hasUsers && (
|
||||
<div className="initial-admin-box">
|
||||
<ShieldAlert size={18} />
|
||||
<div>
|
||||
<strong>Acces admin initial</strong>
|
||||
<span>{status.initialAdminEmail}</span>
|
||||
<code>{DEFAULT_INITIAL_PASSWORD}</code>
|
||||
<small>Change ces identifiants dans Mon compte > Securite apres connexion.</small>
|
||||
{status.initialAdminPasswordIsDefault ? (
|
||||
<>
|
||||
<code>{DEFAULT_INITIAL_PASSWORD}</code>
|
||||
<small>Mot de passe par defaut atteste par le serveur. Change-le dans Mon compte > Securite.</small>
|
||||
</>
|
||||
) : (
|
||||
<small>Utilise le mot de passe configure au demarrage ou deja modifie dans le compte.</small>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user