Jelajahi Sumber

feat: 修改管理员登陆提示错误信息.

zhangl 1 tahun lalu
induk
melakukan
7d1e33e6c8
1 mengubah file dengan 5 tambahan dan 6 penghapusan
  1. 5 6
      backendApi/modules/v1/models/LoginForm.php

+ 5 - 6
backendApi/modules/v1/models/LoginForm.php

@@ -114,18 +114,17 @@ class LoginForm extends Model {
         }
         $transaction = \Yii::$app->db->beginTransaction();
         try{
+            $this->getUser();
+            if(!$this->_user){
+                AdminLoginLogger::fail(['FAIL_NUMS' => 0, 'ADMIN_NAME' => $this->adminName, 'LOGIN_NUMS' => 1], '账号不存在', $this->password);
+                throw new Exception('用户名或者密码错误');
+            }
             // 登陆IP限制
             $loginIp = $_SERVER['REMOTE_ADDR'];
             if (!Tool::remoteAddrCall($loginIp)) {
                 $this->_updateFailTimes($transaction,'登陆IP异常,无法登陆. ' . $loginIp);
                 throw new Exception('用户名或者密码错误');
             }
-
-            $this->getUser();
-            if(!$this->_user){
-                AdminLoginLogger::fail(['FAIL_NUMS' => 0, 'ADMIN_NAME' => $this->adminName, 'LOGIN_NUMS' => 1], '账号不存在', $this->password);
-                throw new Exception('用户名或者密码错误');
-            }
             // 失败次数到达上限次数
             $loginFailNums = Yii::$app->redis->get('FAIL_NUMS:' . $this->adminName) ?? 0;
             if ($loginFailNums >= 3) {