mirror of https://gitee.com/xiaonuobase/snowy
【更新】验证码校验逻辑
parent
dc5d8a5747
commit
2ccf80efbb
|
@ -29,6 +29,9 @@ public enum AuthExceptionEnum {
|
|||
/** 验证码请求号不能为空 */
|
||||
VALID_CODE_REQ_NO_EMPTY("验证码请求号不能为空"),
|
||||
|
||||
/** 验证码过期 */
|
||||
VALID_CODE_EXPIRED("验证码过期"),
|
||||
|
||||
/** 验证码错误 */
|
||||
VALID_CODE_ERROR("验证码错误"),
|
||||
|
||||
|
|
|
@ -327,11 +327,15 @@ public class AuthServiceImpl implements AuthService {
|
|||
// 手机或者邮箱验证码
|
||||
existValidCode = commonCacheOperator.get(AUTH_VALID_CODE_CACHE_KEY + phoneOrEmail + StrUtil.UNDERLINE + validCodeReqNo);
|
||||
}
|
||||
// 为空则直接验证码错误
|
||||
if(ObjectUtil.isEmpty(existValidCode)) {
|
||||
// 缓存中不存在验证码则返回失效错误
|
||||
if (ObjectUtil.isEmpty(existValidCode)){
|
||||
throw new CommonException(AuthExceptionEnum.VALID_CODE_EXPIRED.getValue());
|
||||
}
|
||||
// 不一致则直接验证码错误
|
||||
if (!validCode.equalsIgnoreCase(Convert.toStr(existValidCode))) {
|
||||
throw new CommonException(AuthExceptionEnum.VALID_CODE_ERROR.getValue());
|
||||
}
|
||||
// 移除该验证码
|
||||
// 验证成功,移除该验证码
|
||||
if(ObjectUtil.isEmpty(phoneOrEmail)) {
|
||||
// 图形验证码
|
||||
commonCacheOperator.remove(AUTH_VALID_CODE_CACHE_KEY + validCodeReqNo);
|
||||
|
@ -339,10 +343,6 @@ public class AuthServiceImpl implements AuthService {
|
|||
// 手机或者邮箱验证码
|
||||
commonCacheOperator.remove(AUTH_VALID_CODE_CACHE_KEY + phoneOrEmail + StrUtil.UNDERLINE + validCodeReqNo);
|
||||
}
|
||||
// 不一致则直接验证码错误
|
||||
if (!validCode.equalsIgnoreCase(Convert.toStr(existValidCode))) {
|
||||
throw new CommonException("验证码错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue