{"record":{"id":"657c330c9fc41d40","repo":"paascloud/paascloud-master","slug":"uac10011002","errorCode":"UAC10011002","errorMessage":"找不到用户,loginName=%s","messagePattern":"找不到用户,loginName=(.+?)","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacLoginServiceImpl.java","lineNumber":63,"sourceCode":"\n\t@Resource\n\tprivate UacUserService uacUserService;\n\t@Resource\n\tprivate UacMenuService uacMenuService;\n\n\t@Override\n\tpublic LoginRespDto loginAfter(Long applicationId) {\n\t\tLoginRespDto loginRespDto = new LoginRespDto();\n\t\tString loginName = SecurityUtils.getCurrentLoginName();\n\t\tif (StringUtils.isEmpty(loginName)) {\n\t\t\tlog.error(\"操作超时, 请重新登录 loginName={}\", loginName);\n\t\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(loginName), \"操作超时, 请重新登录\");\n\t\t}\n\n\t\tUacUser uacUser = uacUserService.findByLoginName(loginName);\n\t\tif (PublicUtil.isEmpty(uacUser)) {\n\t\t\tlog.info(\"找不到用户信息 loginName={}\", loginName);\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011002, loginName);\n\t\t}\n\n\t\tLoginAuthDto loginAuthDto = this.getLoginAuthDto(uacUser);\n\t\tList<MenuVo> menuVoList = uacMenuService.getMenuVoList(uacUser.getId(), applicationId);\n\t\tif (PublicUtil.isNotEmpty(menuVoList) && UacConstant.MENU_ROOT.equals(menuVoList.get(0).getMenuCode())) {\n\t\t\tmenuVoList = menuVoList.get(0).getSubMenu();\n\t\t}\n\t\tloginRespDto.setLoginAuthDto(loginAuthDto);\n\t\tloginRespDto.setMenuList(menuVoList);\n\t\treturn loginRespDto;\n\t}\n\n\tprivate LoginAuthDto getLoginAuthDto(UacUser uacUser) {\n\t\tLoginAuthDto loginAuthDto = new LoginAuthDto();\n\t\tloginAuthDto.setUserId(uacUser.getId());\n\t\tloginAuthDto.setUserName(uacUser.getUserName());\n\t\tloginAuthDto.setLoginName(uacUser.getLoginName());\n\t\treturn loginAuthDto;","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacLoginServiceImpl.java#L45-L81","documentation":"loginAfter performs post-login processing: it resolves the user by loginName via uacUserService.findByLoginName. If no user matches it throws UacBizException(UAC10011002) \"找不到用户,loginName=%s\". This usually means the session carried a loginName that no longer maps to an existing account.","triggerScenarios":"Calling loginAfter (or hitting an endpoint that runs it) with a loginName stored in the session/token that no longer exists — account deleted after login, loginName renamed, or a stale/foreign cookie resolving to a nonexistent user.","commonSituations":"User deleted or renamed while their session token was still valid; Redis/session cache surviving a database reset or environment switch; SSO passing a loginName from an external directory that isn't synced into the uac user table.","solutions":["Verify the loginName exists (findByLoginName) before invoking loginAfter; invalidate the session if not.","Clear stale session/Redis token data after database resets or user deletions so dead loginNames aren't replayed.","Catch UacBizException UAC10011002, force logout, and redirect the user to re-authenticate."],"exampleFix":"// before\nuacLoginService.loginAfter(request, loginName); // stale session name\n// after\nUacUser user = uacUserService.findByLoginName(loginName);\nif (user == null) {\n    sessionService.invalidate(sessionId);\n    throw new AuthException(\"session references deleted user; please re-login\");\n}\nuacLoginService.loginAfter(request, loginName);","handlingStrategy":"try-catch","validationCode":"UacUser user = uacUserService.findByLoginName(loginName);\nif (user == null) {\n    // invalidate session/token and force re-login\n}","typeGuard":"null","tryCatchPattern":"try {\n    uacLoginService.loginAfter(request, loginName);\n} catch (UacBizException e) {\n    if (ErrorCodeEnum.UAC10011002.getCode().equals(e.getCode())) {\n        securityContext.logout();\n        throw new AuthException(\"account no longer exists; please log in again\");\n    }\n    throw e;\n}","preventionTips":["Invalidate cached sessions/tokens when a user is deleted or renamed.","Sync external (SSO/LDAP) login names into the uac user table before accepting those sessions.","Clear auth caches after database restores or environment switches."],"tags":["user-not-found","session","authentication"],"backgroundTag":"user-not-found","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"}