public async Task <ResultDto> ModifyPassword(string name, ModifyPasswordInput input) { var result = new ResultDto { Message = "" }; try { var admin = await _adminDomainService.Get(x => x.Name == name); if (admin == null) { result.Message = "账号不存在"; await _operatorLogDomainService.AddError(new OperatorLogEntity { Type = OperatorLogType.修改密码, Content = $"Data={JsonConvert.SerializeObject(input)},ErrorMessage={result.Message}" }); await Commit(); } else if (admin.Password != input.Password.ToMd5()) { result.Message = "密码错误"; await _operatorLogDomainService.AddError(new OperatorLogEntity { Type = OperatorLogType.修改密码, Content = $"Data={JsonConvert.SerializeObject(input)},ErrorMessage={result.Message}" }); await Commit(); } else { admin.Password = input.NewPassword.ToMd5(); await _adminDomainService.Update(admin); await _operatorLogDomainService.AddSuccess(new OperatorLogEntity { Type = OperatorLogType.修改密码, Content = $"Data={JsonConvert.SerializeObject(input)}" }); await Commit(); } } catch (Exception ex) { result.Message = ex.Message; await _operatorLogDomainService.AddError(new OperatorLogEntity { Type = OperatorLogType.修改密码, Content = $"Data={JsonConvert.SerializeObject(input)},ErrorMessage={result.Message}" }); await Commit(); } return(result); }
public async Task ModifyPassword(ModifyPasswordInput input) { if (input.Password != input.Confirm) { throw new BusinessException($"两次输入的新密码不匹配"); } var currentMd5Password = MD5Helper.MD5Encrypt32(input.Current); var user = await _userRepository.FirstOrDefaultAsync(t => t.Id == AdmSession.UserId && t.Password == currentMd5Password); if (user == null) { throw new BusinessException($"当前密码错误,请重试"); } user.Password = MD5Helper.MD5Encrypt32(input.Password); await _userRepository.UpdateAsync(user); }
public ResultMessage <string> Password(ModifyPasswordInput input) { string urlOrMsg; try { var isSuccess = _passowrdProcesssor.ModifyPassword(new JeuciAccount(input.OpenId, input.AccountName, input.OldPassword, AccountOperateType.ModifyPassword), input.NewPassworld, out urlOrMsg); if (isSuccess) { return(new ResultMessage <string>(urlOrMsg, "密码修改成功,请使用新密码登录您的App!")); } return(new ResultMessage <string>(ResultCode.Fail, urlOrMsg)); } catch (Exception e) { return(new ResultMessage <string>(ResultCode.Fail, e.Message)); } }
public async Task <ResultDto> ModifyPassword(int id, ModifyPasswordInput modifyPasswordInput) { var result = new ResultDto { Message = "" }; try { var user = await _userDomainService.Get(id); if (user == null) { result.Message = $"用户 {id} 不存在!"; return(result); } user.Password = modifyPasswordInput.NewPassword.ToMd5(); await _userDomainService.Update(user); await _operatorLogDomainService.AddSuccess(new OperatorLogEntity { Type = OperatorLogType.修改用户密码, Content = $"Id = {id},{JsonConvert.SerializeObject(modifyPasswordInput)}" }); await Commit(); result.IsSuccess = true; } catch (Exception ex) { result.Message = ex.Message; await _operatorLogDomainService.AddError(new OperatorLogEntity { Type = OperatorLogType.修改用户密码, Content = $"Id = {id},Data={JsonConvert.SerializeObject(modifyPasswordInput)},ErrorMessage={ex.Message}" }); await Commit(); } return(result); }
public async Task <IActionResult> ModifyPassword(ModifyPasswordInput input) { await _userService.ModifyPassword(input); return(Ok(ResponseBody.From("密码修改成功"))); }