Ajout de l'authentification (compte unique, JWT, reset par email)
Application mono-utilisateur : inscription unique, connexion par JWT (12 h), protection de toutes les routes de données, réinitialisation de mot de passe par email avec repli de journalisation, onboarding réorganisé en deux étapes (inscription → connexion → profil + véhicule). Backend (SchotzIadKmTracker.Api) : - Entités Compte (singleton) et ResetPasswordToken + migration AjoutAuthentification. - Hachage PasswordHasher, JwtService (HS256, durée configurable), IEmailService (MailKit + repli LoggingEmailService selon Smtp:Host). - AuthService (register 409 si compte existant, login 401 générique, forgot-password non-divulgation, reset à usage unique + expiration), AuthController (5 endpoints publics), DTOs + validateurs FluentValidation. - Sécurité pipeline : JwtBearer + filtre d'autorisation global, UseAuthentication avant UseAuthorization ; /health et /api/auth/* publics. Frontend (schotziad-km-tracker, zoneless + signals) : - AuthService (localStorage), authInterceptor (Bearer + purge/redirection 401), authGuard, écrans Login/Register/ForgotPassword/ResetPassword, routes publiques et protection [authGuard, profilConfigureGuard]. Configuration : .env.example et docker-compose.yml (JWT__SecretKey, durées, Smtp__*). Tests : 54 tests backend (propriétés FsCheck P1–P14, exemples, intégration WebApplicationFactory) + tests frontend (AuthService, authGuard, authInterceptor, ResetPasswordComponent). Suite complète au vert. Spec : .kiro/specs/authentification (requirements, design, tasks).
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<section class="login">
|
||||
<h1>Connexion</h1>
|
||||
|
||||
<form [formGroup]="form" (ngSubmit)="seConnecter()" novalidate>
|
||||
@if (erreur()) {
|
||||
<p class="erreur-globale" role="alert">{{ erreur() }}</p>
|
||||
}
|
||||
|
||||
<div class="champ">
|
||||
<label for="email">Adresse email</label>
|
||||
<input
|
||||
id="email"
|
||||
type="email"
|
||||
formControlName="email"
|
||||
autocomplete="username"
|
||||
autocapitalize="none"
|
||||
spellcheck="false"
|
||||
[attr.aria-invalid]="form.get('email')?.invalid && form.get('email')?.touched"
|
||||
aria-describedby="email-erreur"
|
||||
/>
|
||||
@if (form.get('email')?.touched && form.get('email')?.invalid) {
|
||||
<p id="email-erreur" class="erreur" role="alert">
|
||||
@if (form.get('email')?.hasError('required')) {
|
||||
L'adresse email est obligatoire.
|
||||
} @else if (form.get('email')?.hasError('email')) {
|
||||
L'adresse email n'est pas valide.
|
||||
}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="champ">
|
||||
<label for="motDePasse">Mot de passe</label>
|
||||
<input
|
||||
id="motDePasse"
|
||||
type="password"
|
||||
formControlName="motDePasse"
|
||||
autocomplete="current-password"
|
||||
[attr.aria-invalid]="form.get('motDePasse')?.invalid && form.get('motDePasse')?.touched"
|
||||
aria-describedby="motDePasse-erreur"
|
||||
/>
|
||||
@if (form.get('motDePasse')?.touched && form.get('motDePasse')?.invalid) {
|
||||
<p id="motDePasse-erreur" class="erreur" role="alert">
|
||||
@if (form.get('motDePasse')?.hasError('required')) {
|
||||
Le mot de passe est obligatoire.
|
||||
} @else if (form.get('motDePasse')?.hasError('minlength')) {
|
||||
Le mot de passe doit comporter au moins 8 caractères.
|
||||
}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<button type="submit" class="btn-principal" [disabled]="soumissionEnCours()">
|
||||
{{ soumissionEnCours() ? 'Connexion…' : 'Se connecter' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<nav class="liens" aria-label="Actions du compte">
|
||||
<a routerLink="/forgot-password">Mot de passe oublié ?</a>
|
||||
@if (!compteExiste()) {
|
||||
<a routerLink="/register">Créer un compte</a>
|
||||
}
|
||||
</nav>
|
||||
</section>
|
||||
Reference in New Issue
Block a user