{"record":{"id":"4fe984b58db72733","repo":"paascloud/paascloud-master","slug":"uac10011019","errorCode":"UAC10011019","errorMessage":"UAC10011019","messagePattern":"UAC10011019","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/EmailServiceImpl.java","lineNumber":105,"sourceCode":"\n\t@Override\n\tpublic void sendEmailCode(SendEmailMessage sendEmailMessage, String loginName) {\n\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(loginName), \"用户名不能为空\");\n\t\tString email = sendEmailMessage.getEmail();\n\n\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(email), ErrorCodeEnum.UAC10011018.msg());\n\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(loginName), ErrorCodeEnum.UAC10011007.msg());\n\n\t\t// 解密\n\t\temail = decryptEmail(loginName, email);\n\n\t\tExample example = new Example(UacUser.class);\n\t\tExample.Criteria criteria = example.createCriteria();\n\t\tcriteria.andEqualTo(\"email\", email);\n\t\tcriteria.andNotEqualTo(\"loginName\", loginName);\n\t\tint result = uacUserService.selectCountByExample(example);\n\t\tif (result > 0) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011019);\n\t\t}\n\n\t\tString emailCode = RandomUtil.createNumberCode(6);\n\t\tString key = RedisKeyUtil.getSendEmailCodeKey(loginName, email);\n\t\t// 在redis中绑定验证码\n\t\tredisService.setKey(key, emailCode, 7 * 24, TimeUnit.HOURS);\n\n\t\t// 先写死 类型多了再抽方法\n\t\tMap<String, Object> param = Maps.newHashMap();\n\t\tparam.put(\"loginName\", loginName);\n\t\tparam.put(\"email\", email);\n\t\tparam.put(\"emailCode\", emailCode);\n\t\tparam.put(\"dateTime\", DateUtil.formatDateTime(new Date()));\n\n\t\tSet<String> to = Sets.newHashSet();\n\t\tto.add(email);\n\n\t\tMqMessageData mqMessageData = emailProducer.sendEmailMq(to, UacEmailTemplateEnum.RESET_USER_EMAIL, AliyunMqTopicConstants.MqTagEnum.RESET_LOGIN_PWD, param);","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/EmailServiceImpl.java#L87-L123","documentation":"EmailServiceImpl.sendEmailCode throws UacBizException(UAC10011019) when a selectCountByExample finds more than zero UacUser rows with the given email whose loginName differs from the current user's. This means the email is already bound to another account, so sending a bind/verification email code is refused.","triggerScenarios":"Calling sendEmailCode to bind a new email for user X while another user Y already has that same email recorded in uac_user.","commonSituations":"Users sharing a work email across accounts; re-registering an account with an email previously bound; typos matching someone else's email; merging accounts.","solutions":["Choose an email not already bound to another loginName","Unbind the email from the other account first (update uac_user.email for that account)","Merge the two accounts if they belong to the same person","Show a clear UI message that the email is already in use by another account"],"exampleFix":"// before\nemailService.sendEmailCode(\"alice\", \"shared@corp.com\"); // fails, bob owns the email\n// after\nif (userService.countByEmailExcludingLogin(email, loginName) == 0) { emailService.sendEmailCode(loginName, email); }","handlingStrategy":"validation","validationCode":"int count = userService.countByEmailExcludingLogin(email, loginName); // SELECT COUNT(*) FROM uac_user WHERE email=? AND login_name<>?\nif (count > 0) { /* pick another email before calling sendEmailCode */ }","typeGuard":null,"tryCatchPattern":"try { emailService.sendEmailCode(loginName, email); } catch (UacBizException e) { if (ErrorCodeEnum.UAC10011019.getCode().equals(e.getCode())) { ui.show(\"该邮箱已被其他账号绑定\"); return; } throw e; }","preventionTips":["Check email availability with a dedicated API before submitting the bind form","Enforce unique index on uac_user.email so DB state matches this check","Merge duplicate accounts instead of re-binding shared emails","Show the conflict clearly in UI rather than only a generic error code"],"tags":["email","duplicate-record","uniqueness-constraint","validation"],"backgroundTag":"duplicate-record-conflict","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}