public ActionResult ResetPassword(string token)
 {
     if (_userServices.ValidatePasswordResetRequest(token))
     {
         User   user    = _userServices.GetUser(int.Parse(token.Split('-')[0]));
         string newPass = _userServices.ResetPassword(user.UserID);
         _emailServices.PasswordChanged(user, newPass);
         _userServices.DeletePasswordResetRequest(user.UserID);
         SetSuccess("Password reset, an email as been set to the associated email address of the account");
         return(RedirectToAction("Login"));
     }
     else
     {
         SetError("Invalid reset password token. The token is incorrect or expired. Please submit another reset request");
         return(RedirectToAction("ForgotPassword"));
     }
 }
Exemple #2
0
        public ActionResult Password(PasswordViewModel model, string Password, string NewPassword, string ConfirmPassword)
        {
            SetBreadCrumb("Password");

            if (!_userServices.ValidatePassword(_currentUser, model.CurrentPassword))
            {
                ModelState.AddModelError("CurrentPassword", "Invalid password.");
            }

            if (IsModelValidAndPersistErrors())
            {
                _userServices.UpdatePassword(_currentUser.UserID, NewPassword);
                _emailServices.PasswordChanged(_currentUser, NewPassword);
                SetSuccess("Password changed. An email confirmation has been sent");
            }

            return(RedirectToSelf());
        }