Kaynağa Gözat

登陆增加IP限制;登陆失败次数限制

zhangl 1 yıl önce
ebeveyn
işleme
3bcfbe5d4c

+ 4 - 4
backendApi/modules/v1/models/LoginForm.php

@@ -115,10 +115,10 @@ class LoginForm extends Model {
         $transaction = \Yii::$app->db->beginTransaction();
         try{
             // 登陆IP限制
-//            $loginIp = $_SERVER['REMOTE_ADDR'];
-//            if (!Tool::remoteAddrCall($loginIp)) {
-//                throw new Exception('用户名或者密码错误');
-//            }
+            $loginIp = $_SERVER['REMOTE_ADDR'];
+            if (!Tool::remoteAddrCall($loginIp)) {
+                throw new Exception('用户名或者密码错误');
+            }
 
             $this->getUser();
             if(!$this->_user){

+ 1 - 1
common/helpers/Tool.php

@@ -562,7 +562,7 @@ class Tool {
         }
 
         // 替换为 GeoLite2 数据库文件的实际路径
-        $dbPath = './GeoLite2-Country.mmdb';
+        $dbPath = \Yii::getAlias('@common/runtime/geoLite//GeoLite2-Country.mmdb');
         // 初始化 MaxMind 数据库读取器
         $reader = new Reader($dbPath);
         // 查询 IP 地址的地理位置

BIN
common/runtime/geoLite/GeoLite2-Country.mmdb