public async Task <IActionResult> Authentication2FA(TwoFactorAuthViewModel model) { if (model != null) { SignUpMobileWithOTPResponse response = new SignUpMobileWithOTPResponse(); response.ReturnCode = 200; response.ReturnMsg = "Success"; response.StatusCode = 200; response.StatusMessage = "Done"; return(Ok(response)); } else { ModelState.AddModelError(string.Empty, "Invalid"); return(BadRequest(new ApiError(ModelState))); } //var user = await GetCurrentUserAsync(); //var model = new TwoFactorAuthenticationViewModel //{ // HasAuthenticator = await _userManager.GetAuthenticatorKeyAsync(user) != null, // Is2faEnabled = user.TwoFactorEnabled, // RecoveryCodesLeft = await _userManager.CountRecoveryCodesAsync(user), //}; //return Ok(model); }
public async Task <IActionResult> TwoFactorAuth(TwoFactorAuthViewModel twoFactorAuthViewModel, string returnUrl = null) { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(View(twoFactorAuthViewModel)); } var result = await _rcmSignInManager.TwoFactorSignInAsync("Email", twoFactorAuthViewModel.Code, twoFactorAuthViewModel.PersistentLogin, twoFactorAuthViewModel.RememberClient); if (result.Succeeded) { if (returnUrl != null) { return(LocalRedirect(returnUrl)); } else { return(RedirectToPlatform()); } } else if (result.IsLockedOut) { return(RedirectToAction(nameof(LockedOut))); } return(View(twoFactorAuthViewModel)); }
public async Task <IActionResult> TwoFactorAuth(TwoFactorAuthViewModel model) { if (ModelState.IsValid) { if (model.Code == model.CodeConfirm) { if (DateTime.Now.Minute - model.SendCodeTime.Minute > 5) { string codeTimeOverMessage = "Время действия кода истекло."; HttpContext.Session.SetString("AnswerToSend", codeTimeOverMessage); return(RedirectToAction("Login", "User")); } User user = await _userManager.FindByIdAsync(model.UserId); return(RedirectToAction("SignIn", "Manage", new { UserNameSignIn = user.UserName })); } else { string codeTimeOverMessage = "Неверный код"; HttpContext.Session.SetString("AnswerToSend", codeTimeOverMessage); return(RedirectToAction("Login", "User")); } } else { ModelState.AddModelError(string.Empty, "Неверный код"); } return(View(model)); }