{"record":{"id":"30eb3566d4fcace6","repo":"jeecgboot/JeecgBoot","slug":"500","errorCode":"500","errorMessage":"原手机号不匹配，无法修改密码！","messagePattern":"原手机号不匹配，无法修改密码！","errorType":"exception","errorClass":"JeecgBootException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java","lineNumber":2085,"sourceCode":"\t\t\tthrow new JeecgBootException(\"admin用户，不允许删除！\");\n\t\t}\n\t}\n\n\t@Override\n\tpublic void changePhone(JSONObject json, String username) {\n\t\tString smscode = json.getString(\"smscode\");\n\t\tString phone = json.getString(\"phone\");\n\t\tString type = json.getString(\"type\");\n\t\tif(oConvertUtils.isEmpty(phone)){\n\t\t\tthrow new JeecgBootException(\"请填写原手机号！\");\n\t\t}\n\t\tif(oConvertUtils.isEmpty(smscode)){\n\t\t\tthrow new JeecgBootException(\"请填写验证码！\");\n\t\t}\n\t\t//step1 验证原手机号是否和当前用户匹配\n\t\tSysUser sysUser = userMapper.getUserByNameAndPhone(phone,username);\n\t\tif (null == sysUser){\n\t\t\tthrow new JeecgBootException(\"原手机号不匹配，无法修改密码！\");\n\t\t}\n\t\t//step2 根据类型判断是验证原手机号的验证码还是新手机号的验证码\n\t\t//验证原手机号\n\t\tif(CommonConstant.VERIFY_ORIGINAL_PHONE.equals(type)){\n\t\t\tthis.verifyPhone(phone, smscode);\n\t\t}else if(CommonConstant.UPDATE_PHONE.equals(type)){\n\t\t\t//修改手机号\n\t\t\tString newPhone = json.getString(\"newPhone\");\n\t\t\t//需要验证新手机号和原手机号是否一致，一致不让修改\n\t\t\tif(newPhone.equals(phone)){\n\t\t\t\tthrow new JeecgBootException(\"新手机号与原手机号一致，无法修改！\");\n\t\t\t}\n\t\t\tthis.verifyPhone(newPhone, smscode);\n\t\t\t//step3 新手机号验证码验证成功之后即可修改手机号\n\t\t\tsysUser.setPhone(newPhone);\n\t\t\tuserMapper.updateById(sysUser);\n\t\t}\n\t}","sourceCodeStart":2067,"sourceCodeEnd":2103,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java#L2067-L2103","documentation":"Thrown by SysUserServiceImpl.changePhone step1 when userMapper.getUserByNameAndPhone(phone, username) returns null - the submitted original phone does not belong to the current user account. Reported (misleadingly) as 'cannot modify password' though this is the phone-change flow.","triggerScenarios":"changePhone called with a 'phone' (original phone) that does not match any sys_user row for the given username.","commonSituations":"User mistyped the original phone; the account's phone was changed already; phone stored with country code or formatting differences; username in session differs from the account that owns the phone.","solutions":["Have the user re-enter their current registered phone number exactly as stored.","Check sys_user.phone for the logged-in username and use that value.","Normalize phone format (strip spaces/country code) before comparing if storage is inconsistent.","If the stored phone is wrong, correct it in the DB or via the reset flow."],"exampleFix":"// before: { \"phone\": \"13900000000\", ... }  // wrong original phone\n\n// after: look up the real stored phone\nSysUser u = userMapper.getUserByName(username);\n// populate form with u.getPhone(), then submit","handlingStrategy":"validation","validationCode":"SysUser u = userMapper.getUserByNameAndPhone(phone, username);\nif (u == null) return Result.error(\"原手机号不匹配\");","typeGuard":"boolean phoneBelongsToUser(String phone, String username) {\n  return userMapper.getUserByNameAndPhone(phone, username) != null;\n}","tryCatchPattern":"try { userService.changePhone(json, username); }\ncatch (JeecgBootException e) {\n  if (e.getMessage().contains(\"原手机号不匹配\")) return Result.error(\"请输入正确的原手机号\");\n  throw e;\n}","preventionTips":["Pre-fill the original phone from sys_user for the logged-in user.","Normalize phone formatting before comparison.","Note the message says 'password' but means phone - do not be misled."],"tags":["phone","validation","user-management"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}