refactor: change name enums
This commit is contained in:
@ -17,7 +17,7 @@ public class Admin : ISaveSettings
|
||||
public required string Email { get; set; }
|
||||
public required string PasswordHash { get; set; }
|
||||
public required string Salt { get; set; }
|
||||
public SecondFactor SecondFactor { get; set; } = SecondFactor.None;
|
||||
public TwoFactorAuthenticator TwoFactorAuthenticator { get; set; } = TwoFactorAuthenticator.None;
|
||||
public string? Secret { get; set; }
|
||||
|
||||
public void SaveSetting()
|
||||
|
@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Mirea.Api.Dto.Common;
|
||||
using Mirea.Api.Dto.Requests;
|
||||
using Mirea.Api.Dto.Responses;
|
||||
using Mirea.Api.Endpoint.Common.Attributes;
|
||||
using Mirea.Api.Endpoint.Common.Exceptions;
|
||||
using Mirea.Api.Endpoint.Common.Services;
|
||||
@ -29,7 +28,7 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
|
||||
|
||||
[HttpPost("Login")]
|
||||
[BadRequestResponse]
|
||||
public async Task<ActionResult<AuthenticationStep>> Login([FromBody] LoginRequest request)
|
||||
public async Task<ActionResult<TwoFactorAuthentication>> Login([FromBody] LoginRequest request)
|
||||
{
|
||||
var userEntity = user.Value;
|
||||
|
||||
@ -46,20 +45,20 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
|
||||
Email = userEntity.Email,
|
||||
PasswordHash = userEntity.PasswordHash,
|
||||
Salt = userEntity.Salt,
|
||||
SecondFactor = userEntity.SecondFactor,
|
||||
TwoFactorAuthenticator = userEntity.TwoFactorAuthenticator,
|
||||
SecondFactorToken = userEntity.Secret
|
||||
},
|
||||
HttpContext, request.Password);
|
||||
|
||||
return Ok(tokenResult ? AuthenticationStep.None : AuthenticationStep.TotpRequired);
|
||||
return Ok(tokenResult ? TwoFactorAuthentication.None : TwoFactorAuthentication.TotpRequired);
|
||||
}
|
||||
|
||||
[HttpGet("Login")]
|
||||
[BadRequestResponse]
|
||||
public async Task<ActionResult<AuthenticationStep>> Login([FromQuery] string code)
|
||||
public async Task<ActionResult<TwoFactorAuthentication>> Login([FromQuery] string code)
|
||||
{
|
||||
var tokenResult = await auth.LoginAsync(GetCookieParams(), HttpContext, code);
|
||||
return Ok(tokenResult ? AuthenticationStep.None : AuthenticationStep.TotpRequired);
|
||||
return Ok(tokenResult ? TwoFactorAuthentication.None : TwoFactorAuthentication.TotpRequired);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user