{"record":{"id":"5ac7b0141826b8f6","repo":"wuyouzhuguli/SpringAll","slug":"error-5ac7b0","errorCode":null,"errorMessage":"验证码已过期！","messagePattern":"验证码已过期！","errorType":"validation","errorClass":"ValidateCodeException","httpStatus":null,"severity":"warning","filePath":"60.Spring-Security-Logout/src/main/java/cc/mrbird/validate/code/ValidateCodeFilter.java","lineNumber":55,"sourceCode":"                return;\n            }\n        }\n        filterChain.doFilter(httpServletRequest, httpServletResponse);\n    }\n\n    private void validateCode(ServletWebRequest servletWebRequest) throws ServletRequestBindingException {\n        ImageCode codeInSession = (ImageCode) sessionStrategy.getAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE);\n        String codeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), \"imageCode\");\n\n        if (StringUtils.isBlank(codeInRequest)) {\n            throw new ValidateCodeException(\"验证码不能为空！\");\n        }\n        if (codeInSession == null) {\n            throw new ValidateCodeException(\"验证码不存在！\");\n        }\n        if (codeInSession.isExpire()) {\n            sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE);\n            throw new ValidateCodeException(\"验证码已过期！\");\n        }\n        if (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), codeInRequest)) {\n            throw new ValidateCodeException(\"验证码不正确！\");\n        }\n        sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE);\n\n    }\n\n}\n","sourceCodeStart":37,"sourceCodeEnd":65,"githubUrl":"https://github.com/wuyouzhuguli/SpringAll/blob/614d2578d9495acf53cc02f2dee9c6131cc5e51a/60.Spring-Security-Logout/src/main/java/cc/mrbird/validate/code/ValidateCodeFilter.java#L37-L65","documentation":"Thrown by ValidateCodeFilter.validateCode (Logout project) when the session ImageCode is expired (isExpire() true, default 60s). The expired code is removed before throwing.","triggerScenarios":"More than 60s elapsed between GET /code/image and POST /login; stale captcha submitted.","commonSituations":"Long idle on the login form; short TTL; slow entry.","solutions":["Submit within the 60-second window.","Auto-refresh the captcha image before it expires.","Raise expireIn in createImageCode.","Show a client countdown and re-fetch the image at zero."],"exampleFix":"// before\nint expireIn = 60;\n\n// after\nint expireIn = 180;","handlingStrategy":"validation","validationCode":"// client-side countdown for the 60s TTL\nlet ttl = 60;\nif (--ttl <= 0) { refreshCaptcha(); ttl = 60; }","typeGuard":null,"tryCatchPattern":"// AuthenticationFailureHandler: on expiry, refresh image and ask to retry.","preventionTips":["Auto-refresh the captcha before expiry.","Show a countdown.","Tune expireIn to realistic think-time."],"tags":["spring-security","captcha","session","expiry","validation","java"],"backgroundTag":null,"analyzedSha":"614d2578d9495acf53cc02f2dee9c6131cc5e51a","analyzedAt":"2026-08-14T04:40:03.488Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}