refactor: transfer two factor method to security

This commit is contained in:
2024-11-02 01:09:15 +03:00
parent 3811d879ab
commit c5ba1cfcca
3 changed files with 27 additions and 6 deletions

View File

@ -54,11 +54,11 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
return Ok(tokenResult.ConvertToDto());
}
[HttpGet("Login")]
[HttpPost("2FA")]
[BadRequestResponse]
public async Task<ActionResult<TwoFactorAuthentication>> Login([FromQuery] string code)
public async Task<ActionResult<TwoFactorAuthentication>> TwoFactorAuth([FromBody] TwoFactorAuthRequest request)
{
var tokenResult = await auth.LoginAsync(GetCookieParams(), HttpContext, code);
var tokenResult = await auth.LoginAsync(GetCookieParams(), HttpContext, request.Method.ConvertFromDto(), request.Code);
return Ok(tokenResult ? TwoFactorAuthentication.None : TwoFactorAuthentication.TotpRequired);
}