mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 04:47:11 +08:00
fix: 短信验证码的参数名称修改
This commit is contained in:
parent
7be21be8d6
commit
ba7a543eb0
@ -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);
|
||||
}
|
||||
|
||||
|
@ -86,13 +86,13 @@ public class SmsAuthenticationProvider implements AuthenticationProvider {
|
||||
// 短信验证码校验
|
||||
Map<String, Object> 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("验证码错误");
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public final class SmsParameterNames {
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
public static final String VERIFY_CODE = "verifyCode";
|
||||
public static final String CODE = "code";
|
||||
|
||||
|
||||
private SmsParameterNames() {
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user