Exemple #1
0
        public async Task <BaseHttpActionResult> ChangePassword([Required] ChangePasswordViewModel changePasswordViewModel)
        {
            //load user using username and provided password
            var user = await _repo.FindUser(this.User.Identity.GetUserName(), changePasswordViewModel.CurrentPassword);

            if (user == null)
            {
                return(ErrorHttpActionResult.GenerateBadRequest("The current password is invalid"));
            }

            IdentityResult result = await _repo.ChangePassword(user.Id, changePasswordViewModel.CurrentPassword, changePasswordViewModel.NewPassword);

            return(GetResult(result));
        }
 public bool ChangePassword(ChangePasswordModel changePasswordModel)
 {
     try
     {
         var foundAccount = _repository.GetAccountByLogin(changePasswordModel.Login);
         if (foundAccount != null)
         {
             if (HashHelper.ComputeHash(changePasswordModel.Password).Equals(foundAccount.PasswordHash))
             {
                 _repository.ChangePassword(foundAccount.AccountId, HashHelper.ComputeHash(changePasswordModel.NewPassword));
                 return(true);
             }
         }
     }
     catch { }
     return(false);
 }
Exemple #3
0
 public bool ChangePassword(string token, string newPassword)
 {
     return(_authenticationService.ChangePassword(token, newPassword));
 }
Exemple #4
0
 public void ChangePassword(string login, string newPassword)
 {
     _authenticationRepository.ChangePassword(login, newPassword);
 }