瀏覽代碼

Merge branch 'master' of http://59.57.98.130:3000/jjhc/jucai

linwu 4 月之前
父節點
當前提交
3cfcc53a5a

+ 8 - 1
app/Http/Controllers/Web/Auth/ResetPasswordController.php

@@ -7,6 +7,7 @@ use App\Http\Controllers\Web\WebBaseController;
 use App\Services\Auth\AuthService;
 use App\Services\Common\EmailService;
 use App\Services\Common\SmsService;
+use App\Services\Common\TencentCaptchaService;
 use App\Validators\ResetPasswordValidatorRequest;
 
 class ResetPasswordController extends WebBaseController
@@ -24,6 +25,8 @@ class ResetPasswordController extends WebBaseController
      */
     private $emailService;
 
+    private $tencentCaptchaService;
+
 
     /**
      * ResetPasswordController constructor.
@@ -31,11 +34,12 @@ class ResetPasswordController extends WebBaseController
      * @param AuthService $authService
      * @param EmailService $emailService
      */
-    public function __construct(SmsService $smsService, AuthService $authService, EmailService $emailService)
+    public function __construct(SmsService $smsService, AuthService $authService, EmailService $emailService, TencentCaptchaService $tencentCaptchaService)
     {
         $this->smsService = $smsService;
         $this->authService = $authService;
         $this->emailService = $emailService;
+        $this->tencentCaptchaService = $tencentCaptchaService;
     }
 
     public function passwordRequest()
@@ -52,6 +56,9 @@ class ResetPasswordController extends WebBaseController
             $token=$this->authService->resetPasswordToken($request->all());
             return $this->sendSuccessResponse(['url'=>route('password.reset', ['token'=>$token])]);
         } elseif ($request->type == 'email') {
+            if(!$this->tencentCaptchaService->check(request()->input('randstr'),request()->input('ticket'),request()->ip())){
+                return $this->sendErrorResponse("验证码不通过,请重新验证");
+            }
             $token=$this->authService->resetPasswordToken($request->all());
             $this->emailService->setCallback('App\Services\Auth\AuthService', 'sendEmailHook', [$request->email, $token])
             ->sendAuthMail($request->email, EmailService::TEMPLATE_PASSWORD_RESET);

+ 61 - 20
public/themes/default/views/app/auth/password_request.blade.php

@@ -78,6 +78,7 @@
                         <div class="clear"></div>
                     </div>
                     <div class="btnbox">
+
                         <input class="utype" type="hidden" name="utype" value="1">
                         <input type="hidden" name="type" value="mobile">
                         {{csrf_field()}}
@@ -96,6 +97,9 @@
                         <div class="clear"></div>
                     </div>
                     <div class="btnbox">
+                        <input type="hidden" name="ticket" id="ticket">
+                        <input type="hidden" name="bizState" id="bizState">
+                        <input type="hidden" name="randstr" id="randstr">
                         <input class="utype" type="hidden" name="utype" value="1">
                         <input type="hidden" name="type" value="email">
                         {{csrf_field()}}
@@ -133,6 +137,23 @@
         var captcha_open ={{config('aix.system.site_safety.site_vo_code.captcha_open', 0) }};
 
         var captcha_callback = function(res){
+            if(res.hasOwnProperty('errorMessage')){
+                alert(res.errorMessage)
+            }
+            if(res.ret == 0){
+                console.log('行为验证通过');
+
+                $("#ticket_mobile").val(res.ticket);
+                $("#bizState_mobile").val(res.bizState);
+                $("#randstr_mobile").val(res.randstr);
+                toSetSms(res);
+            }else{
+                console.log('用户主动关闭验证码')
+            }
+            console.log('callback:', res);
+        };
+
+        var captcha_callback_email = function(res){
             if(res.hasOwnProperty('errorMessage')){
                 alert(res.errorMessage)
             }
@@ -142,13 +163,34 @@
                 $("#ticket").val(res.ticket);
                 $("#bizState").val(res.bizState);
                 $("#randstr").val(res.randstr);
-                toSetSms(res);
+                $.ajax({
+                    url: '{{route('password.request')}}',
+                    cache: false,
+                    async: false,
+                    type: 'post',
+                    dataType: 'json',
+                    data: $('#getPassByEmailForm').serialize(),
+                    success: function(json) {
+                        disapperTooltip("remind", "该邮箱没有注册账号");
+                        $('#email').focus();
+                        return false;
+                    },
+                    error:function(data){
+                        var error_obj=eval('(' + data.responseText + ')');
+                        if(data.status==400) {//业务错误
+
+
+                        }
+                    }
+                });
             }else{
                 console.log('用户主动关闭验证码')
             }
             console.log('callback:', res);
         };
+
         var captcha = new TencentCaptcha('196587903', captcha_callback, {});
+        var captcha_email = new TencentCaptcha('196587903', captcha_callback_email, {});
 
         //找回用户类型
         $('.find_type').click(function(event) {
@@ -170,6 +212,24 @@
             $('.J_listitme_group').eq(indexValue).show().siblings('.J_listitme_group').hide();
         });
 
+        $("#email_reset").click(function (){
+            var emailValue = $.trim($('#email').val());
+            if (emailValue == '') {
+                disapperTooltip("remind", "请输入邮箱");
+                $('#email').focus();
+                return false;
+            };
+            if (emailValue != "" && !regularEmail.test(emailValue)) {
+                disapperTooltip("remind", "请输入正确的邮箱");
+                $('#email').focus();
+                return false;
+            }
+            captcha.show();
+
+
+
+        })
+
         // 点击获取验证码先判断是否输入了手机号
         $('#J_getverificode').click(function() {
             var mobileValue = $.trim($('#mobile').val());
@@ -254,25 +314,6 @@
                 }
             });
         }
-        // if (captcha_open) {
-        //     //发送短信
-        //     var handler = function(captchaObj) {
-        //         captchaObj.appendTo("#popup-captcha");
-        //         captchaObj.onSuccess(function() {
-        //             var result = captchaObj.getValidate();
-        //             toSetSms(result);
-        //         });
-        //
-        //         captchaObj.onError(function() {
-        //
-        //         });
-        //         $('#btnCheck').on('click', function () {
-        //             captchaObj.verify();
-        //
-        //         });
-        //     };
-        //     gt_init(handler);
-        // }
 
     </script>
     <script>