diff --git a/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsAuthenticationConverter.java b/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsAuthenticationConverter.java index 74983fcd2..9e5ace9fd 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsAuthenticationConverter.java +++ b/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsAuthenticationConverter.java @@ -66,11 +66,11 @@ public class SmsAuthenticationConverter implements AuthenticationConverter { } // 验证码(必需) - String verifyCode = parameters.getFirst(SmsParameterNames.VERIFY_CODE); - if (StrUtil.isBlank(verifyCode)) { + String code = parameters.getFirst(SmsParameterNames.CODE); + if (StrUtil.isBlank(code)) { OAuth2EndpointUtils.throwError( OAuth2ErrorCodes.INVALID_REQUEST, - SmsParameterNames.VERIFY_CODE, + SmsParameterNames.CODE, OAuth2EndpointUtils.ACCESS_TOKEN_REQUEST_ERROR_URI); } diff --git a/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsAuthenticationProvider.java b/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsAuthenticationProvider.java index 49dce26ee..846802d2a 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsAuthenticationProvider.java +++ b/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsAuthenticationProvider.java @@ -86,13 +86,13 @@ public class SmsAuthenticationProvider implements AuthenticationProvider { // 短信验证码校验 Map additionalParameters = smsAuthenticationToken.getAdditionalParameters(); String mobile = (String) additionalParameters.get(SmsParameterNames.MOBILE); - String verifyCode = (String) additionalParameters.get(SmsParameterNames.VERIFY_CODE); + String code = (String) additionalParameters.get(SmsParameterNames.CODE); - if (!verifyCode.equals("666666")) { // 666666 是后门,因为短信收费,正式环境删除这个if + if (!code.equals("666666")) { // 666666 是后门,因为短信收费,正式环境删除这个if String codeKey = RedisConstants.LOGIN_SMS_CODE_PREFIX + mobile; String cacheCode = (String) redisTemplate.opsForValue().get(codeKey); - if (!StrUtil.equals(verifyCode, cacheCode)) { + if (!StrUtil.equals(code, cacheCode)) { throw new OAuth2AuthenticationException("验证码错误"); } } diff --git a/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsParameterNames.java b/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsParameterNames.java index a4bb3e5c0..493ce843a 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsParameterNames.java +++ b/youlai-auth/src/main/java/com/youlai/auth/oauth2/extension/sms/SmsParameterNames.java @@ -32,7 +32,7 @@ public final class SmsParameterNames { /** * 验证码 */ - public static final String VERIFY_CODE = "verifyCode"; + public static final String CODE = "code"; private SmsParameterNames() { diff --git a/youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsAuthenticationTests.java b/youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsAuthenticationTests.java index a23d803f1..3f017e29b 100644 --- a/youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsAuthenticationTests.java +++ b/youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsAuthenticationTests.java @@ -32,7 +32,7 @@ public class SmsAuthenticationTests { this.mvc.perform(post("/oauth2/token") .param(OAuth2ParameterNames.GRANT_TYPE, "sms_code") .param("mobile", "18866668888") - .param("verifyCode", "666666") + .param("code", "666666") .headers(headers)) .andDo(print()) .andExpect(status().isOk())