diff --git a/Endpoint/Controllers/V1/AuthController.cs b/Endpoint/Controllers/V1/AuthController.cs index 4453f65..529b29a 100644 --- a/Endpoint/Controllers/V1/AuthController.cs +++ b/Endpoint/Controllers/V1/AuthController.cs @@ -164,10 +164,6 @@ public class AuthController(IOptionsSnapshot user, IOptionsSnapshot user, IOptionsSnapshot revokedToken.AddTokenToRevokedAsync(token, accessTokenService.GetExpireDateTime(token)); - private async Task VerifyUserOrThrowError(RequestContextInfo requestContext, User user, string password, + private async Task VerifyUserOrThrowError(RequestContextInfo requestContext, User user, string password, string username, CancellationToken cancellation = default) { - if (passwordService.VerifyPassword(password, user.Salt, user.PasswordHash)) + if ((user.Email.Equals(username, StringComparison.OrdinalIgnoreCase) || user.Username.Equals(username, StringComparison.OrdinalIgnoreCase)) && + passwordService.VerifyPassword(password, user.Salt, user.PasswordHash)) return; var failedLoginCacheName = $"{requestContext.Fingerprint}_login_failed"; @@ -151,11 +152,11 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I return true; } - public async Task LoginAsync(CookieOptionsParameters cookieOptions, User user, HttpContext context, string password, CancellationToken cancellation = default) + public async Task LoginAsync(CookieOptionsParameters cookieOptions, User user, HttpContext context, string password, string username, CancellationToken cancellation = default) { var requestContext = new RequestContextInfo(context, cookieOptions); - await VerifyUserOrThrowError(requestContext, user, password, cancellation); + await VerifyUserOrThrowError(requestContext, user, password, username, cancellation); if (user.TwoFactorAuthenticator == TwoFactorAuthenticator.None) {