Browse Source

opt:修改密码功能优化

master
zds 1 month ago
parent
commit
9301db1f8a
  1. 5
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java

5
lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java

@ -108,10 +108,11 @@ public class UserController {
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getString("oldPass"));
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getString("newPass"));
SysUser user = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, SecurityUtils.getCurrentUsername()));
if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(oldPass, "salt"))) {
if (!user.getPassword().equals(SaSecureUtil.md5BySalt(oldPass, "salt"))) {
throw new BadRequestException("修改失败,旧密码错误");
}
if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(newPass, "salt"))) {
if (user.getPassword().equals(SaSecureUtil.md5BySalt(newPass, "salt"))) {
throw new BadRequestException("新密码不能与旧密码相同");
}
user.setPassword(SaSecureUtil.md5BySalt(newPass, "salt"));

Loading…
Cancel
Save