public ActionResult Confirm(ChangePasswordFromResetKeyInputModel model)
{
if (ModelState.IsValid)
{
try
{
BrockAllen.MembershipReboot.UserAccount account;
if (this.userAccountService.ChangePasswordFromResetKey(model.Key, model.Password, out account))
{
AuthenticationFailureCode failureCode;
this.userAccountService.Authenticate(this.userAccountService.Configuration.DefaultTenant,
account.Username, model.Password, out account, out failureCode);
if (failureCode == AuthenticationFailureCode.None)
{
this.authenticationService.SignIn(account);
if (account.RequiresTwoFactorAuthCodeToSignIn())
{
return RedirectToAction("TwoFactorAuthCodeLogin", "Login");
}
if (account.RequiresTwoFactorCertificateToSignIn())
{
return RedirectToAction("CertificateLogin", "Login");
}
}
return RedirectToAction("Success");
}
else
{
ModelState.AddModelError("", "Error changing password. The key might be invalid.");
}
}
catch (ValidationException ex)
{
ModelState.AddModelError("", ex.Message);
}
}
return View();
}