Просмотр исходного кода

wesmiler 更新第5期更新代码合并

wesmiler 4 лет назад
Родитель
Сommit
57af7f601e

+ 5 - 2
public/themes/admin_simpleboot3/admin/login.html

@@ -73,14 +73,14 @@
                     </div>
                     <div id="type2" class="typeBox" style="display: none;">
                         <div class="form-group">
-                            <input type="text" id="mobile" class="form-control" name="username"
+                            <input type="text" id="mobile" class="form-control" name="mobile"
                                    placeholder="{:lang('USERNAME_OR_EMAIL')}" title="{:lang('USERNAME_OR_EMAIL')}"
                                    value="{:cookie('admin_username')}" data-rule-required="true" data-msg-required="">
                         </div>
 
                         <div class="form-group">
                             <div style="position: relative;">
-                                <input type="text" name="captcha" placeholder="验证码" class="form-control captcha">
+                                <input type="text" name="code" placeholder="验证码" class="form-control captcha">
                                 <button type="button" class="time" onclick="getCode()">获取验证码</button>
                             </div>
                         </div>
@@ -145,6 +145,9 @@
             if (res.code == 1) {
                 layer.msg(res.msg)
             } else {
+                time = 60;
+                clearInterval(timerId);
+                $(".time").text('获取验证码');
                 layer.msg(res.msg)
             }
         },'json')

+ 30 - 21
vendor/thinkcmf/cmf-app/src/admin/controller/PublicController.php

@@ -83,13 +83,16 @@ class PublicController extends AdminBaseController
         }
 
         $captcha = $this->request->param('captcha');
-        if (empty($captcha)) {
-            $this->error(lang('CAPTCHA_REQUIRED'));
-        }
+        $code = $this->request->param('code');
+
 
         $name = $this->request->param("username");
+        $mobile = $this->request->param("mobile");
         $loginType = input('loginType', 1);
         if ($loginType == 1) {
+            if (empty($captcha)) {
+                $this->error(lang('CAPTCHA_REQUIRED'));
+            }
 
             //验证码
             if (!cmf_captcha_check($captcha)) {
@@ -109,16 +112,20 @@ class PublicController extends AdminBaseController
                 $where['user_login'] = $name;
             }
         } else {
-            $result = Sms::checkCode($name, $captcha,'admin');
+            if (empty($code)) {
+                $this->error(lang('CAPTCHA_REQUIRED'));
+            }
+
+            $result = Sms::checkCode($mobile, $code,'admin');
             if ($result !== true) {
                 $this->error(lang($result));
             }
 
-            if (empty($name)) {
+            if (empty($mobile)) {
                 $this->error('请填写正确格式手机号码');
             }
 
-            $where['mobile'] = $name;
+            $where['mobile'] = $mobile;
 
         }
 
@@ -126,22 +133,24 @@ class PublicController extends AdminBaseController
         $result = Db::name('user')->where($where)->find();
         if (!empty($result) && ($result['user_type'] == 1 || $result['user_type'] == 3)) {
 
-            // 登录IP来源验证
-            $ip = get_client_ip();
-            if ($result['check_ip']) {
-                $blackList = explode(',', $result['check_ip']);
-                if ($blackList && !in_array($ip, $blackList)) {
-                    $this->error(lang('USER_IP_LIMIT'), '', $ip);
-                }
-            } else if ($result['user_type'] != 3) {
-                $blackList = config('app.ipBlackList');
-                if ($blackList && !preg_match($blackList, $ip)) {
-                    $this->error(lang('USER_IP_LIMIT'), '', $ip);
+            if($loginType == 1){
+                // 登录IP来源验证
+                $ip = get_client_ip();
+                if ($result['check_ip']) {
+                    $blackList = explode(',', $result['check_ip']);
+                    if ($blackList && !in_array($ip, $blackList)) {
+                        $this->error(lang('USER_IP_LIMIT'), '', $ip);
+                    }
+                } else if ($result['user_type'] != 3) {
+                    $blackList = config('app.ipBlackList');
+                    if ($blackList && !preg_match($blackList, $ip)) {
+                        $this->error(lang('USER_IP_LIMIT'), '', $ip);
+                    }
                 }
-            }
 
-            if ($loginType == 1 && !cmf_compare_password($pass, $result['user_pass'])) {
-                $this->error(lang('PASSWORD_NOT_RIGHT'));
+                if (!cmf_compare_password($pass, $result['user_pass'])) {
+                    $this->error(lang('PASSWORD_NOT_RIGHT'));
+                }
             }
 
             $groups = Db::name('RoleUser')
@@ -185,7 +194,7 @@ class PublicController extends AdminBaseController
         // 发送处理
         $result = Sms::sendCode($mobile, ['tpName' => 'code'], 'admin');
         if (!is_array($result)) {
-            $this->error(is_numeric($result) ? $result : 1009);
+            $this->error(lang(is_numeric($result) ? $result : 1009));
         }
 
         $this->success('验证码发送成功');