public async Task <IActionResult> SecondAuth(SecondAuthViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); var app = (await _apiService.AppInfoAsync(model.AppId)).App; var authenticatorCode = model.VerifyCode.Replace(" ", string.Empty).Replace("-", string.Empty); var result = await _signInManager.TwoFactorAuthenticatorSignInAsync(authenticatorCode, true, model.DoNotAskMeOnIt); if (result.Succeeded) { return(await _authManager.FinishAuth(user, model, app.ForceConfirmation, app.TrustedApp)); } else if (result.IsLockedOut) { ModelState.AddModelError(string.Empty, "The account is locked for too many attempts."); } else { ModelState.AddModelError(string.Empty, "The code is invalid. Please check and try again."); } var viewModel = new SecondAuthViewModel { AppId = model.AppId, RedirectUri = model.RedirectUri, State = model.State, }; return(View(viewModel)); }
public IActionResult SecondAuth(FinishAuthInfo model) { if (!ModelState.IsValid) { return(View("AuthError")); } var viewModel = new SecondAuthViewModel { AppId = model.AppId, RedirectUri = model.RedirectUri, State = model.State }; return(View(viewModel)); }