public JsonResult UpdateUserPassword(Guid userId, [FromBody] UserInfoUpdatePasswordInDTO userPasswordUpdate) { var identity = _contextAccessor.HttpContext.User.Identity; var userInfoId = Security.GetUserInfoId(identity); if (userPasswordUpdate == null || userId == null) { throw new Exception("Something is missing in the payload or Id"); } var result = _userInfoService.UpdatePassword(userPasswordUpdate); return(new JsonResult(result)); }
public bool UpdatePassword(UserInfoUpdatePasswordInDTO userPasswordUpdate) { try { var currentUser = _userInfoRepository.FindByID(userPasswordUpdate.UserInfoId); if (currentUser == null) { return(false); } currentUser.Password = Security.HashPassword(userPasswordUpdate.Password); currentUser.ModifiedOn = Localization.GetUTCDateNow(); currentUser.ModifiedBy = userPasswordUpdate.UserInfoId; _userInfoRepository.Update(currentUser); } catch (Exception ex) { throw new Exception(ex.Message); } return(true); }