diff --git a/Endpoint/Controllers/V1/AuthController.cs b/Endpoint/Controllers/V1/AuthController.cs index e689d8a..2639165 100644 --- a/Endpoint/Controllers/V1/AuthController.cs +++ b/Endpoint/Controllers/V1/AuthController.cs @@ -7,6 +7,7 @@ using Mirea.Api.Dto.Common; using Mirea.Api.Dto.Requests; using Mirea.Api.Endpoint.Common.Attributes; using Mirea.Api.Endpoint.Common.Exceptions; +using Mirea.Api.Endpoint.Common.MapperDto; using Mirea.Api.Endpoint.Common.Services; using Mirea.Api.Endpoint.Configuration.Model; using Mirea.Api.Security.Common.Domain; @@ -50,7 +51,7 @@ public class AuthController(IOptionsSnapshot user, AuthService auth, Pass }, HttpContext, request.Password); - return Ok(tokenResult ? TwoFactorAuthentication.None : TwoFactorAuthentication.TotpRequired); + return Ok(tokenResult.ConvertToDto()); } [HttpGet("Login")] diff --git a/Security/Services/AuthService.cs b/Security/Services/AuthService.cs index 5c71a9f..6ace1c8 100644 --- a/Security/Services/AuthService.cs +++ b/Security/Services/AuthService.cs @@ -121,7 +121,7 @@ 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, CancellationToken cancellation = default) { var requestContext = new RequestContextInfo(context, cookieOptions); @@ -130,7 +130,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I if (user.TwoFactorAuthenticator == TwoFactorAuthenticator.None) { await GenerateAuthTokensAsync(cookieOptions, context, requestContext, user.Id.ToString(), cancellation); - return true; + return TwoFactorAuthenticator.None; } var firstAuthToken = new FirstAuthToken(requestContext) @@ -142,7 +142,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I await cache.SetAsync(GetFirstAuthCacheKey(requestContext.Fingerprint), firstAuthToken, absoluteExpirationRelativeToNow: LifetimeFirstAuth, cancellationToken: cancellation); - return false; + return user.TwoFactorAuthenticator; } public async Task RefreshTokenAsync(CookieOptionsParameters cookieOptions, HttpContext context, CancellationToken cancellation = default)