Na most van kész a 2 faktoros authentikáció ! :)
This commit is contained in:
@@ -14,7 +14,8 @@ namespace WorkFlowCheck.Web.Pages.Account
|
||||
|
||||
private readonly IUserService _userService;
|
||||
[BindProperty]
|
||||
public UserDTO UserSimpleDTO { get; set; }
|
||||
public User2FADTO User2FADTO { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public LoginModel(IUserService userService)
|
||||
@@ -25,14 +26,31 @@ namespace WorkFlowCheck.Web.Pages.Account
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
public async Task<IActionResult> OnPostLogin2F1([FromBody] UserSimpleDTO userSimpleDTO)
|
||||
{
|
||||
var response = await _userService.Authenticate(UserSimpleDTO.UserName, UserSimpleDTO.Password);
|
||||
var response = await _userService.Authenticate2F1(userSimpleDTO.UserName, userSimpleDTO.Password);
|
||||
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
|
||||
var token = response.Data.JwtToken;
|
||||
return new JsonResult(new { success = true, data = response.Data });
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessage = "Hibás bejelentkezés!";
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
}
|
||||
public async Task<IActionResult> OnPostLogin2F2([FromBody] User2FADTO user2FADTO)
|
||||
{
|
||||
var response = await _userService.Authenticate2F2(user2FADTO.UserName,
|
||||
user2FADTO.Password,
|
||||
user2FADTO.Code,
|
||||
user2FADTO.Token2FA);
|
||||
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
|
||||
var token = response.Data.JwtToken;
|
||||
|
||||
Response.Cookies.Append("AuthToken", token, new CookieOptions
|
||||
{
|
||||
@@ -42,11 +60,11 @@ namespace WorkFlowCheck.Web.Pages.Account
|
||||
Expires = DateTimeOffset.UtcNow.AddMinutes(30)
|
||||
});
|
||||
|
||||
return RedirectToPage("/Index"); // vagy ahová szeretnéd
|
||||
return new JsonResult(new { success = true });
|
||||
}
|
||||
|
||||
ErrorMessage = "Hibás bejelentkezés!";
|
||||
return Page();
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user