Browse Source

开发 和 测试环境 固定短信验证码 不校验

chao 4 năm trước cách đây
mục cha
commit
3cdb3b8942

+ 7 - 0
src/main/java/com/caimei365/user/components/CommonService.java

@@ -6,6 +6,7 @@ import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.utils.ValidateUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -25,6 +26,8 @@ public class CommonService {
     private BaseMapper baseMapper;
     @Resource
     private LoginMapper loginMapper;
+    @Value("${spring.cloud.config.profile}")
+    private String profile;
     /**
      * 校验邮箱
      * @param email 邮箱
@@ -51,6 +54,10 @@ public class CommonService {
         if (result != null) {return result;}
         if (StringUtils.isNotBlank(smsCode)){
             String redisSmsCode = (String) redisService.get("code:" + mobile);
+            // 开发 和 测试环境 固定短信验证码 666666
+            if ("dev".equals(profile) || "beta".equals(profile)){
+                redisSmsCode = (null != redisSmsCode && !"null".equals(redisSmsCode) ? redisSmsCode : "666666");
+            }
             if (!redisSmsCode.equals(smsCode)) {
                 return "手机验证码错误";
             }