Переглянути джерело

wesmiler ECY 画画交易平台

APPLE 2 роки тому
батько
коміт
26a685d174

+ 4 - 0
application/cmgadm/controller/Index.php

@@ -101,10 +101,14 @@ class Index extends Backend
         if ($this->auth->autologin()) {
             $this->redirect($url);
         }
+
         $background = Config::get('fastadmin.login_background');
         $background = stripos($background, 'http') === 0 ? $background : config('site.cdnurl') . $background;
+        $config = \app\common\model\Config::getConfigByGroup('basic');
+        $googleVerify = isset($config['google_verify'])? $config['google_verify']['value'] : 0;
         $this->view->assign('background', $background);
         $this->view->assign('title', __('Login'));
+        $this->view->assign('google_verify',$googleVerify);
         Hook::listen("admin_login_init", $this->request);
         return $this->view->fetch();
     }

+ 11 - 0
application/cmgadm/controller/general/Googlecode.php

@@ -34,4 +34,15 @@ class Googlecode extends Backend
         $this->view->assign('qrcode', $qrcode);
         return $this->view->fetch();
     }
+
+    /**
+     * 绑定
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function bind()
+    {
+        $admin = Admin::where(['id'=> $this->auth->id])->field('id,username,nickname,google_key')->find();
+    }
 }

+ 11 - 2
application/cmgadm/view/general/googlecode/index.html

@@ -48,8 +48,17 @@
         <div class="qrcode">
             <img src="{$qrcode}" alt="">
         </div>
-        <div class="name"><span>账号:{$admin.username}</span></div>
+        <div class="name"><span>账号:{$admin.username}</span> <button onclick="bind()">确定绑定</button></div>
         <div class="url">验证器安卓下载地址:<a href="https://google-authenticator.en.softonic.com/android" target="_blank">:立即下载</a></div>
         <div class="url">验证器IOS下载地址<a href="https://apps.apple.com/cn/app/google-authenticator/id388497605" target="_blank">:立即下载</a></div>
     </div>
-</div>
+</div>
+<script>
+    function bind(){
+        $.get('general/googlecode/bind',function(res){
+            if(res.code == 0){
+
+            }
+        },'json')
+    }
+</script>

+ 6 - 0
application/cmgadm/view/index/login.html

@@ -85,6 +85,12 @@
                                     </span>
                                 </div>
                                 {/if}
+                                {if $google_verify}
+                                <div class="input-group">
+                                    <div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div>
+                                    <input type="text" name="google_code" class="form-control" placeholder="{:__('谷歌验证码')}" data-rule="{:__('谷歌验证码')}:required;length(6)" />
+                                </div>
+                                {/if}
                                 <div class="form-group">
                                     <label class="inline" for="keeplogin">
                                         <input type="checkbox" name="keeplogin" id="keeplogin" value="1" />