diff --git a/server/like-admin/src/main/java/com/mdd/admin/service/system/impl/SystemAuthAdminServiceImpl.java b/server/like-admin/src/main/java/com/mdd/admin/service/system/impl/SystemAuthAdminServiceImpl.java index 6e564d73..10e4b2ca 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/service/system/impl/SystemAuthAdminServiceImpl.java +++ b/server/like-admin/src/main/java/com/mdd/admin/service/system/impl/SystemAuthAdminServiceImpl.java @@ -303,6 +303,9 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService { model.setUpdateTime(System.currentTimeMillis() / 1000); if (systemAuthAdminParam.getPassword() != null && !systemAuthAdminParam.getPassword().equals("")) { + if (systemAuthAdminParam.getPassword().length() < 6 || systemAuthAdminParam.getPassword().length() > 20) { + throw new OperateException("密码必须在6~20位"); + } String salt = ToolsUtil.randomString(5); String pwd = ToolsUtil.makeMd5( systemAuthAdminParam.getPassword().trim() + salt); model.setPassword(pwd); @@ -311,6 +314,12 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService { systemAuthAdminMapper.updateById(model); this.cacheAdminUserByUid(systemAuthAdminParam.getId()); + + Integer id = LikeAdminThreadLocal.getAdminId(); + if (systemAuthAdminParam.getPassword() != null && systemAuthAdminParam.getId().equals(id)) { + String token = Objects.requireNonNull(RequestUtil.handler()).getHeader("token"); + RedisUtil.del(AdminConfig.backstageTokenKey + token); + } } /** @@ -343,6 +352,10 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService { throw new OperateException("当前密码不正确!"); } + if (systemAuthAdminParam.getPassword().length() > 20 || systemAuthAdminParam.getPassword().length() < 6) { + throw new OperateException("密码必须在6~20位!"); + } + String salt = ToolsUtil.randomString(5); String pwd = ToolsUtil.makeMd5( systemAuthAdminParam.getPassword().trim() + salt); model.setPassword(pwd);