{"record":{"id":"2adff4b219d6421e","repo":"wuyouzhuguli/SpringAll","slug":"error-2adff4","errorCode":null,"errorMessage":"验证码不正确！","messagePattern":"验证码不正确！","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"64.Spring-Security-OAuth2-Customize/src/main/java/cc/mrbird/security/validate/smscode/SmsCodeFilter.java","lineNumber":55,"sourceCode":"            }\n        }\n        filterChain.doFilter(httpServletRequest, httpServletResponse);\n    }\n\n    private void validateCode(ServletWebRequest servletWebRequest) throws Exception {\n        String smsCodeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), \"smsCode\");\n        String mobileInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), \"mobile\");\n\n        String codeInRedis = redisCodeService.get(servletWebRequest, mobileInRequest);\n\n        if (StringUtils.isBlank(smsCodeInRequest)) {\n            throw new Exception(\"验证码不能为空！\");\n        }\n        if (codeInRedis == null) {\n            throw new Exception(\"验证码已过期！\");\n        }\n        if (!StringUtils.equalsIgnoreCase(codeInRedis, smsCodeInRequest)) {\n            throw new Exception(\"验证码不正确！\");\n        }\n        redisCodeService.remove(servletWebRequest, mobileInRequest);\n\n    }\n}","sourceCodeStart":37,"sourceCodeEnd":60,"githubUrl":"https://github.com/wuyouzhuguli/SpringAll/blob/614d2578d9495acf53cc02f2dee9c6131cc5e51a/64.Spring-Security-OAuth2-Customize/src/main/java/cc/mrbird/security/validate/smscode/SmsCodeFilter.java#L37-L60","documentation":"Generic Exception thrown when equalsIgnoreCase(codeInRedis, smsCodeInRequest) is false: the submitted SMS code does not match the value stored in Redis for 'SMS_CODE:deviceId:mobile'. Comparison is case-insensitive. The code is removed from Redis only on success, so a wrong attempt does not consume it.","triggerScenarios":"User entered the wrong 6-digit code; the code in Redis belongs to a different mobile/deviceId key; the code was retried with a stale value after a resend.","commonSituations":"Typo in the 6-digit code; resend overwrote the key and the user entered the older code; deviceId differed so a different key's code was compared.","solutions":["Re-enter the exact code from the latest SMS for the same mobile and deviceId.","Ensure deviceId is identical between /code/sms and /login/mobile so the same Redis key is read.","Avoid multiple resends before submitting; use only the most recent code."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Sanity-check the 6-digit code and key consistency before submit.\nconst code = form.get('smsCode');\nif (!/^\\d{6}$/.test(code || '')) { showFieldError('smsCode','请输入6位短信验证码'); return; }\n// also ensure deviceId + mobile match what was used at /code/sms","typeGuard":null,"tryCatchPattern":"try { await smsLogin(); }\ncatch (e) {\n  if (/不正确/.test(e.message)) { await resendSms(); /* enter the latest code */ }\n  else handleError(e);\n}","preventionTips":["Use only the most recent SMS code; avoid overlapping resends.","Keep deviceId and mobile identical between generation and validation.","Treat a mismatch as retryable, not fatal."],"tags":["sms","captcha","validation","redis","oauth2"],"backgroundTag":null,"analyzedSha":"614d2578d9495acf53cc02f2dee9c6131cc5e51a","analyzedAt":"2026-08-14T04:40:03.488Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}