public async Task <IActionResult> TwoFactorLogin(TwoFactorLoginModel model, string returnUrl = null) { if (!this.ModelState.IsValid) { return(View(model)); } if (model == null) { throw new ApplicationException("Model is null"); } string code = model.TwoFactorCode; Microsoft.AspNetCore.Identity.SignInResult result = await this._signInManager.TwoFactorAuthenticatorSignInAsync( model.TwoFactorCode, model.RememberMe, model.RememberMachine).ConfigureAwait(false); if (result.Succeeded) { return(await this.RedirectToLocal(returnUrl).ConfigureAwait(false)); } else { this.ModelState.AddModelError("model.Code", "Invalid Code"); return(View()); } }
public async Task <IActionResult> TwoFactorLogin(bool rememberMe, string returnUrl = null) { ConfaqueUser user = await this._signInManager.GetTwoFactorAuthenticationUserAsync().ConfigureAwait(false); if (user == null) { throw new ApplicationException("User is null"); } TwoFactorLoginModel model = new TwoFactorLoginModel() { RememberMe = rememberMe }; ViewData["ReturnUrl"] = returnUrl; return(View(model)); }