Skip to content

Commit

Permalink
fix: 用户修改密码增加后端接口校验
Browse files Browse the repository at this point in the history
  • Loading branch information
ulleo committed Jun 5, 2023
1 parent deb80ff commit 7d4dab6
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,17 @@ public boolean resetPwd(ResetPwdRequest request, UserDto currentUser) {
if (!"local".equalsIgnoreCase(user.getSource())) {
throw new RuntimeException("非云管本地创建的用户无法修改密码");
}
if (StringUtils.equals(request.getOldPassword(), request.getNewPassword())) {
throw new RuntimeException("新旧密码相同");
}
if (!MD5Util.md5(request.getOldPassword()).equalsIgnoreCase(user.getPassword())) {
throw new RuntimeException("旧密码错误");
}

if (!request.getNewPassword().matches("^(?!.*\\s)(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\\W_]).{8,30}$")) {
throw new RuntimeException("有效密码:8-30位,英文大小写字母+数字+特殊字符");
}

user.setPassword(MD5Util.md5(request.getNewPassword()));
user.setUpdateTime(null);
this.updateById(user);
Expand Down

0 comments on commit 7d4dab6

Please # to comment.