public IActionResult ChangePassword(ChangePasswordViewModel vm, string tokenString) { // Get and Validate token var errorMessage = ""; IResetToken token; var isReal = _passwordResetService.GetToken(tokenString, out token); if (!isReal) { errorMessage += "Reset token invalid"; return(RedirectToAction("ChangePassword", new { tokenString = tokenString, errorMessage = errorMessage })); } // Validate if dead var isDead = _passwordResetService.AuthenticateToken(token); if (isDead) { errorMessage += "Reset token invalid"; return(RedirectToAction("ChangePassword", new { tokenString = tokenString, errorMessage = errorMessage })); } // Attempt to change password var success = _passwordResetService.UseToken(token, vm.NewPassword, out errorMessage); if (!success) { return(RedirectToAction("ChangePassword", new { tokenString = tokenString, errorMessage = errorMessage })); } var basevm = _viewModelFactory.Resolve <BaseViewModel>(); return(View("PasswordChanged", basevm)); }