{"record":{"id":"ae7e15cdf2d599ac","repo":"elunez/eladmin","slug":"error-ae7e15","errorCode":null,"errorMessage":"新密码不能与旧密码相同","messagePattern":"新密码不能与旧密码相同","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java","lineNumber":165,"sourceCode":"            if (currentLevel > optLevel) {\n                throw new BadRequestException(\"角色权限不足，不能删除：\" + userService.findById(id).getUsername());\n            }\n        }\n        userService.delete(ids);\n        return new ResponseEntity<>(HttpStatus.OK);\n    }\n\n    @ApiOperation(\"修改密码\")\n    @PostMapping(value = \"/updatePass\")\n    public ResponseEntity<Object> updateUserPass(@RequestBody UserPassVo passVo) throws Exception {\n        String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getOldPass());\n        String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass());\n        UserDto user = userService.findByName(SecurityUtils.getCurrentUsername());\n        if(!passwordEncoder.matches(oldPass, user.getPassword())){\n            throw new BadRequestException(\"修改失败，旧密码错误\");\n        }\n        if(passwordEncoder.matches(newPass, user.getPassword())){\n            throw new BadRequestException(\"新密码不能与旧密码相同\");\n        }\n        userService.updatePass(user.getUsername(),passwordEncoder.encode(newPass));\n        return new ResponseEntity<>(HttpStatus.OK);\n    }\n\n    @ApiOperation(\"重置密码\")\n    @PutMapping(value = \"/resetPwd\")\n    public ResponseEntity<Object> resetPwd(@RequestBody Set<Long> ids) {\n        String pwd = passwordEncoder.encode(\"123456\");\n        userService.resetPwd(ids, pwd);\n        return new ResponseEntity<>(HttpStatus.OK);\n    }\n\n    @ApiOperation(\"修改头像\")\n    @PostMapping(value = \"/updateAvatar\")\n    public ResponseEntity<Object> updateUserAvatar(@RequestParam MultipartFile avatar){\n        return new ResponseEntity<>(userService.updateAvatar(avatar), HttpStatus.OK);\n    }","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/elunez/eladmin/blob/55fbf705956949697dbd68bf9003776609d3d029/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java#L147-L183","documentation":"Thrown by UserController.updateUserPass (line 165) on POST /api/users/updatePass when the new password (RSA-decrypted) matches the current stored hash. eladmin forbids password reuse on change: after verifying the old password is correct, it rejects a new password identical to the old one. Note the ordering — you only see this error when the old password was already validated.","triggerScenarios":"User submits the same password for old and new fields; auto-fill fills newPass with the current password; password manager re-suggesting the just-used credential.","commonSituations":"Password-expiry flows where the user satisfies the prompt with their existing password; browser autofill populating both fields; testing scripts that reuse a constant password across change operations.","solutions":["Choose a genuinely different new password and resubmit.","Clear autofill on the new-password input (autocomplete=\"new-password\") so browsers do not repeat the old one.","In automated tests, rotate the password constant each run (e.g. append a counter) instead of reusing it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (oldPass === newPass) {\n  notifyError('新密码不能与旧密码相同'); // mirrors server rule\n  return;\n}\nawait axios.post('/api/users/updatePass', { oldPass: encrypt(oldPass), newPass: encrypt(newPass) });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Client-side equality check before submit.","autocomplete=\"new-password\" on the new field to stop autofill reuse."],"tags":["password","validation","eladmin","user","policy"],"backgroundTag":null,"analyzedSha":"55fbf705956949697dbd68bf9003776609d3d029","analyzedAt":"2026-08-14T11:56:12.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}