wesley.chen hace 7 años
padre
commit
dec949a013

+ 1 - 0
app/Http/Controllers/Api/V1/HomeController.php

xqd
@@ -244,6 +244,7 @@ class HomeController extends Controller
      *          ]
      *
      *     }
+     *
      * }
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request

+ 1 - 0
composer.json

xqd
@@ -8,6 +8,7 @@
         "php": ">=7.0.0",
         "dingo/api": "2.0.*@dev",
         "fideloper/proxy": "~3.3",
+        "germey/geetest": "^3.0",
         "intervention/image": "^2.4",
         "laravel/framework": "5.5.*",
         "laravel/passport": "^2.0",

+ 2 - 0
config/app.php

xqd xqd
@@ -181,6 +181,7 @@ return [
         Intervention\Image\ImageServiceProvider::class,
         Maatwebsite\Excel\ExcelServiceProvider::class,
         Overtrue\LaravelWeChat\ServiceProvider::class,
+        Germey\Geetest\GeetestServiceProvider::class
     ],
 
     /*
@@ -232,6 +233,7 @@ return [
         'Image' => Intervention\Image\Facades\Image::class,
         'Excel' => Maatwebsite\Excel\Facades\Excel::class,
         'EasyWeChat' => Overtrue\LaravelWeChat\Facade::class,
+        'Geetest' => Germey\Geetest\Geetest::class
     ],
 
 ];

+ 91 - 0
config/geetest.php

xqd
@@ -0,0 +1,91 @@
+<?php
+return [
+
+	/*
+	|--------------------------------------------------------------------------
+	| Config Language
+	|--------------------------------------------------------------------------
+	|
+	| Here you can config your yunpian api key from yunpian provided.
+	|
+	| Options: ['zh-cn', 'zh-tw', 'en', 'ja', 'ko']
+	|
+	*/
+	'lang' => 'zh-cn',
+
+	/*
+	|--------------------------------------------------------------------------
+	| Config Geetest Id
+	|--------------------------------------------------------------------------
+	|
+	| Here you can config your yunpian api key from yunpian provided.
+	|
+	*/
+	'id' => 'b46d1900d0a894591916ea94ea91bd2c',
+
+	/*
+	|--------------------------------------------------------------------------
+	| Config Geetest Key
+	|--------------------------------------------------------------------------
+	|
+	| Here you can config your yunpian api key from yunpian provided.
+	|
+	*/
+	'key' => '36fc3fe98530eea08dfc6ce76e3d24c4',
+
+	/*
+	|--------------------------------------------------------------------------
+	| Config Geetest URL
+	|--------------------------------------------------------------------------
+	|
+	| Here you can config your geetest url for ajax validation.
+	|
+	*/
+	'url' => '/geetest',
+
+	/*
+	|--------------------------------------------------------------------------
+	| Config Geetest Protocol
+	|--------------------------------------------------------------------------
+	|
+	| Here you can config your geetest url for ajax validation.
+	| 
+	| Options: http or https
+	|
+	*/
+	'protocol' => 'http',
+
+	/*
+	|--------------------------------------------------------------------------
+	| Config Geetest Product
+	|--------------------------------------------------------------------------
+	|
+	| Here you can config your geetest url for ajax validation.
+	| 
+	| Options: float, popup, custom, bind
+	|
+	*/
+	'product' => 'float',
+
+	/*
+	|--------------------------------------------------------------------------
+	| Config Client Fail Alert Text
+	|--------------------------------------------------------------------------
+	|
+	| Here you can config the alert text when it failed in client.
+	|
+	*/
+	'client_fail_alert' => '请正确完成验证码操作',
+
+	/*
+	|--------------------------------------------------------------------------
+	| Config Server Fail Alert
+	|--------------------------------------------------------------------------
+	|
+	| Here you can config the alert text when it failed in server (two factor validation).
+	|
+	*/
+	'server_fail_alert' => '验证码校验失败',
+
+
+];

+ 4 - 0
resources/views/admin/auth/login.blade.php

xqd
@@ -30,6 +30,10 @@
                 <div class="form-group">
                     <input type="password" name="password" class="form-control" placeholder="密码" required="">
                 </div>
+                <div class="form-group">
+                    {!! Geetest::render() !!}
+                </div>
+                
                 <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
                 <button type="submit" class="btn btn-primary block full-width m-b">登 录</button>
             </form>

+ 1 - 1
resources/views/admin/major/info/index.blade.php

xqd
@@ -26,7 +26,7 @@
                             </div>
                         </form>
                         @if(role('Major/Info/create'))
-                            <div class="col-sm-3 pull-right">
+                            <div class="col-sm-4 pull-right">
                                 <a href="{{ U('Major/Info/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
 
                                 <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" action="{{ U('Major/Info/import')}}">

+ 1 - 1
resources/views/admin/student/count/index.blade.php

xqd
@@ -26,7 +26,7 @@
                             </div>
                         </form>
                         @if(role('Student/Count/create'))
-                            <div class="col-sm-3 pull-right">
+                            <div class="col-sm-4 pull-right">
                                 <a href="{{ U('Student/Count/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
                                 <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" action="{{ U('Student/Count/import')}}">
                                     {{csrf_field()}}

+ 50 - 0
resources/views/vendor/geetest/geetest.blade.php

xqd
@@ -0,0 +1,50 @@
+<script src="http://cdn.bootcss.com/jquery/2.1.0/jquery.min.js"></script>
+<script src="https://static.geetest.com/static/tools/gt.js"></script>
+<div id="{{ $captchaid }}"></div>
+<p id="wait-{{ $captchaid }}" class="show">正在加载验证码...</p>
+@define use Illuminate\Support\Facades\Config
+<script>
+    var geetest = function(url) {
+        var handlerEmbed = function(captchaObj) {
+            $("#{{ $captchaid }}").closest('form').submit(function(e) {
+                var validate = captchaObj.getValidate();
+                if (!validate) {
+                    alert('{{ Config::get('geetest.client_fail_alert')}}');
+                    e.preventDefault();
+                }
+            });
+            captchaObj.appendTo("#{{ $captchaid }}");
+            captchaObj.onReady(function() {
+                $("#wait-{{ $captchaid }}")[0].className = "hide";
+            });
+            if ('{{ $product }}' == 'popup') {
+                captchaObj.bindOn($('#{{ $captchaid }}').closest('form').find(':submit'));
+                captchaObj.appendTo("#{{ $captchaid }}");
+            }
+        };
+        $.ajax({
+            url: url + "?t=" + (new Date()).getTime(),
+            type: "get",
+            dataType: "json",
+            success: function(data) {
+                initGeetest({
+                    gt: data.gt,
+                    challenge: data.challenge,
+                    product: "{{ $product?$product:Config::get('geetest.product', 'float') }}",
+                    offline: !data.success,
+                    new_captcha: data.new_captcha,
+                    lang: '{{ Config::get('geetest.lang', 'zh-cn') }}',
+                    http: '{{ Config::get('geetest.protocol', 'http') }}' + '://'
+                }, handlerEmbed);
+            }
+        });
+    };
+    (function() {
+        geetest('{{ $url?$url:Config::get('geetest.url', 'geetest') }}');
+    })();
+</script>
+<style>
+    .hide {
+        display: none;
+    }
+</style>