public void UpdatePassword(UpdatePasswordDataInfo updatePassword) { if (string.IsNullOrEmpty(updatePassword.NewPassword)) { throw new MissingDomainObjectException("新密码不能为空"); } if (string.IsNullOrEmpty(updatePassword.OldPassword)) { throw new MissingDomainObjectException("旧密码不能为空"); } SystemUser existUser = db.SystemUser.FirstOrDefault(n => n.ID == updatePassword.ID && n.Password == updatePassword.OldPassword); if (existUser == null) { throw new DuplicatedDomainObjectException("密码验证错误"); } if (existUser != null) { existUser.Password = updatePassword.NewPassword; db.SaveChanges(); AddSystemLog(new SystemLogDataInfo() { ModulePage = "SystemUser", Remark = "修改了密码", CreationDate = DateTime.Now, CreationUserID = CurrentAdminUserId, }); } }
public HttpResponseMessage UpdatePassWord(UpdatePasswordDataInfo updatePassword) { updatePassword.ID = CurrentUserID; updatePassword.NewPassword = EncrypManager.Encode(updatePassword.NewPassword); updatePassword.OldPassword = EncrypManager.Encode(updatePassword.OldPassword); SystemUserService.UpdatePassword(updatePassword); return(ResultJson.BuildJsonResponse(null, Models.MessageType.Information, "修改成功")); }