|
|
@@ -11,16 +11,10 @@ use MaxMind\Db\InvalidDatabaseException;
|
|
|
use MaxMind\Db\AddressNotFoundException;
|
|
|
class IpFilter extends Component
|
|
|
{
|
|
|
- public function init()
|
|
|
- {
|
|
|
- parent::init();
|
|
|
- Yii::$app->on(Application::EVENT_BEFORE_REQUEST, [$this, 'checkIp']);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @throws BadRequestHttpException
|
|
|
*/
|
|
|
- public function checkIp()
|
|
|
+ public function frontApiCheck()
|
|
|
{
|
|
|
$request = Yii::$app->request;
|
|
|
$getParams = Yii::$app->request->get();
|
|
|
@@ -31,8 +25,10 @@ class IpFilter extends Component
|
|
|
if (!self::remoteAddrCall($remoteAddr)) {
|
|
|
Yii::warning('GET 参数: ' . json_encode(is_array($getParams) ? $getParams : [], JSON_PRETTY_PRINT), __METHOD__);
|
|
|
Yii::warning('POST 参数: ' . json_encode(is_array($postParams) ? $getParams : [], JSON_PRETTY_PRINT), __METHOD__);
|
|
|
- throw new BadRequestHttpException('用户名或者密码错误');
|
|
|
+ return false;
|
|
|
}
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|