From ba7a543eb0d06c893e474cf9ceec91b9460ffbdb Mon Sep 17 00:00:00 2001 From: hxr <1490493387@qq.com> Date: Tue, 5 Mar 2024 00:23:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=9F=AD=E4=BF=A1=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81=E7=9A=84=E5=8F=82=E6=95=B0=E5=90=8D=E7=A7=B0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oauth2/extension/sms/SmsAuthenticationConverter.java | 6 +++--- .../oauth2/extension/sms/SmsAuthenticationProvider.java | 6 +++--- .../youlai/auth/oauth2/extension/sms/SmsParameterNames.java | 2 +- .../java/com/youlai/auth/oauth2/SmsAuthenticationTests.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) 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())