public ActionResult TwoFactorAuthCodeLogin(string button, TwoFactorAuthInputModel model) { var ctx = Request.GetOwinContext(); var id = ctx.GetIdFromTwoFactorCookie(); if (id == null) { // if the temp cookie is expired, then make the login again return(RedirectToAction("Index")); } if (button == "signin") { if (ModelState.IsValid) { BrockAllen.MembershipReboot.UserAccount account; if (userAccountService.AuthenticateWithCode(id.Value, model.Code, out account)) { authSvc.SignIn(account); if (userAccountService.IsPasswordExpired(account)) { return(RedirectToAction("Index", "ChangePassword")); } if (Url.IsLocalUrl(model.ReturnUrl)) { return(Redirect(model.ReturnUrl)); } return(RedirectToAction("Index", "AccountHome")); } else { ModelState.AddModelError("", "Invalid Code"); } } } if (button == "resend") { ModelState.Clear(); this.userAccountService.SendTwoFactorAuthenticationCode(this.User.GetUserID()); } return(View("TwoFactorAuthCodeLogin", model)); }
public ActionResult TwoFactorAuthCodeLogin(string button, TwoFactorAuthInputModel model) { if (!User.HasUserID()) { // if the temp cookie is expired, then make the login again return(RedirectToAction("Index")); } if (button == "signin") { if (ModelState.IsValid) { HierarchicalUserAccount account; if (userAccountService.AuthenticateWithCode(this.User.GetUserID(), model.Code, out account)) { authSvc.SignIn(account); if (userAccountService.IsPasswordExpired(account)) { return(RedirectToAction("Index", "ChangePassword")); } if (Url.IsLocalUrl(model.ReturnUrl)) { return(Redirect(model.ReturnUrl)); } return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Invalid Code"); } } } if (button == "resend") { ModelState.Clear(); this.userAccountService.SendTwoFactorAuthenticationCode(this.User.GetUserID()); } return(View("TwoFactorAuthCodeLogin", model)); }