zjh
2024-12-19 e14e4217b3f53a5cad511b4331cd7c0a40a40db2
ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysProfileController.java
@@ -1,5 +1,6 @@
package com.ltkj.web.controller.system;
import com.ltkj.common.utils.sign.RsaUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -93,12 +94,24 @@
        LoginUser loginUser = getLoginUser();
        String userName = loginUser.getUsername();
        String password = loginUser.getPassword();
        try {
            oldPassword = RsaUtils.decryptByPrivateKey(oldPassword);
            newPassword = RsaUtils.decryptByPrivateKey(newPassword);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if(userName.equals("10001")){
            oldPassword=userName+oldPassword;
        }
        if (!SecurityUtils.matchesPassword(oldPassword, password)) {
            return error("修改密码失败,旧密码错误");
        }
        if (SecurityUtils.matchesPassword(newPassword, password)) {
            return error("新密码不能与旧密码相同");
        }
        if(userName.equals("10001")){
            newPassword=userName+newPassword;
        }
        if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) {
            // 更新缓存用户密码
            loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));