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).
27 lines
912 B
C#
27 lines
912 B
C#
namespace SchotzIadKmTracker.Api.Services;
|
|
|
|
/// <summary>
|
|
/// Implémentation de repli de <see cref="IEmailService"/> qui n'envoie aucun
|
|
/// email mais journalise le lien de réinitialisation via <see cref="ILogger"/>
|
|
/// au niveau <c>Information</c>. Utilisée lorsqu'aucun serveur SMTP n'est
|
|
/// configuré (<c>Smtp:Host</c> vide), notamment en développement.
|
|
/// </summary>
|
|
public class LoggingEmailService : IEmailService
|
|
{
|
|
private readonly ILogger<LoggingEmailService> _logger;
|
|
|
|
public LoggingEmailService(ILogger<LoggingEmailService> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public Task EnvoyerLienResetAsync(string destinataire, string lienReset, CancellationToken ct)
|
|
{
|
|
_logger.LogInformation(
|
|
"Lien de réinitialisation pour {Destinataire} : {LienReset}",
|
|
destinataire, lienReset);
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|