Browse Source

1、解决小程序企业登录需要滑块验证码问题

rayson 3 months ago
parent
commit
054541ae50

+ 16 - 10
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/auth/MdeEnterpriseAuthServiceImpl.java

@@ -312,16 +312,22 @@ public class MdeEnterpriseAuthServiceImpl implements MdeEnterpriseAuthService {
 
     @Override
     public void resetPassword(AppEnterpriseResetPasswordReqVO reqVO) {
-        if (captchaEnable) {
-            // 校验验证码
-            ValidationUtils.validate(validator, reqVO, AppEnterpriseResetPasswordReqVO.CodeEnableGroup.class);
-            CaptchaVO captchaVO = new CaptchaVO();
-            captchaVO.setCaptchaVerification(reqVO.getCaptchaVerification());
-            ResponseModel response = captchaService.verification(captchaVO);
-            // 验证不通过
-            if (!response.isSuccess()) {
-                // 创建登录失败日志(验证码不正确)
-                throw exception(MDE_AUTH_LOGIN_CAPTCHA_CODE_ERROR, response.getRepMsg());
+        String userAgent = Objects.requireNonNull(ServletUtils.getUserAgent()).toLowerCase();
+        if (!userAgent.contains("micromessenger")
+                && !userAgent.contains("wechatdevtools")
+                && !userAgent.contains("miniprogram")) {
+            // 不是小程序登录要验证图形
+            if (captchaEnable) {
+                // 校验验证码
+                ValidationUtils.validate(validator, reqVO, AppEnterpriseResetPasswordReqVO.CodeEnableGroup.class);
+                CaptchaVO captchaVO = new CaptchaVO();
+                captchaVO.setCaptchaVerification(reqVO.getCaptchaVerification());
+                ResponseModel response = captchaService.verification(captchaVO);
+                // 验证不通过
+                if (!response.isSuccess()) {
+                    // 创建登录失败日志(验证码不正确)
+                    throw exception(MDE_AUTH_LOGIN_CAPTCHA_CODE_ERROR, response.getRepMsg());
+                }
             }
         }
         Object code = redisTemplate.opsForValue().get(reqVO.getEmail());