{"record":{"id":"e96e49b74f254698","repo":"jeecgboot/JeecgBoot","slug":"error-e96e49","errorCode":null,"errorMessage":"用户不存在!","messagePattern":"用户不存在!","errorType":"exception","errorClass":"JeecgBoot401Exception","httpStatus":401,"severity":"error","filePath":"jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java","lineNumber":116,"sourceCode":"    /**\n     * 验证Token\n     */\n    public static boolean verifyToken(String token, CommonAPI commonApi, RedisUtil redisUtil) {\n        if (StringUtils.isBlank(token)) {\n            throw new JeecgBoot401Exception(\"token不能为空!\");\n        }\n\n        // 解密获得username，用于和数据库进行对比\n        String username = JwtUtil.getUsername(token);\n        if (username == null) {\n            throw new JeecgBoot401Exception(\"token非法无效!\");\n        }\n\n        // 查询用户信息\n        LoginUser user = TokenUtils.getLoginUser(username, commonApi, redisUtil);\n        //LoginUser user = commonApi.getUserByName(username);\n        if (user == null) {\n            throw new JeecgBoot401Exception(\"用户不存在!\");\n        }\n        // 判断用户状态\n        if (user.getStatus() != 1) {\n            throw new JeecgBoot401Exception(\"账号已被锁定,请联系管理员!\");\n        }\n        // 校验token是否超时失效 & 或者账号密码是否错误\n        if (!jwtTokenRefresh(token, username, user.getPassword(), redisUtil)) {\n            // 用户登录Token过期提示信息\n            String userLoginTokenErrorMsg = oConvertUtils.getString(redisUtil.get(CommonConstant.PREFIX_USER_TOKEN_ERROR_MSG + token));\n            throw new JeecgBoot401Exception(oConvertUtils.isEmpty(userLoginTokenErrorMsg)? CommonConstant.TOKEN_IS_INVALID_MSG: userLoginTokenErrorMsg);\n        }\n        return true;\n    }\n\n    /**\n     * 刷新token（保证用户在线操作不掉线）\n     * @param token\n     * @param userName","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java#L98-L134","documentation":"Thrown by TokenUtils.verifyToken after the token is decoded and the username is extracted, but getLoginUser(username,...) returns null — the user does not exist in Redis (or, for the CommonAPI path, in the DB). Returns HTTP 401. It indicates the token refers to a user the backend can no longer find.","triggerScenarios":"The user was deleted or never existed; the Redis user cache was flushed/expired while the JWT itself is still structurally valid; a multi-node deploy where the user logged in on a node whose Redis is a different instance; or the username claim in the token was tampered to refer to a non-existent account.","commonSituations":"Admin deleted a user account mid-session; Redis was restarted/cleared; wrong Redis DB index configured (spring.redis.database) so the user cache is in another db; deployment switched from standalone to cluster Redis without migrating sessions.","solutions":["Treat this as a hard session end: clear the client token and require re-login.","Verify the Redis connection and database index are consistent across all app nodes (spring.redis.database, host, port).","Confirm the user still exists and has status=1 in sys_user_table.","If the cache was intentionally cleared, broadcast a logout/refresh so clients re-authenticate."],"exampleFix":"// before: stale token after user deletion\n// user clicks around -> 401 '用户不存在!'\n\n// after (frontend)\nif (err.response.status === 401) {\n  Vue.ls.clear();\n  router.push('/user/login');\n}","handlingStrategy":"fallback","validationCode":"LoginUser u = TokenUtils.getLoginUser(username, commonApi, redisUtil);\nif (u == null) { /* clear client token, redirect to login */ }","typeGuard":"public static boolean userResolvable(String username){\n    return username != null && TokenUtils.getLoginUser(username, commonApi, redisUtil) != null;\n}","tryCatchPattern":"try { TokenUtils.verifyToken(token, ...); }\ncatch (JeecgBoot401Exception e) { clearSession(); redirect(\"/login\"); }","preventionTips":["Keep Redis persistent or replicate sessions during deploys.","Use the same Redis DB index across nodes.","Handle user-deletion by revoking tokens."],"tags":["authentication","jwt","redis","session","jeecg-boot","http-401"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}