| Current Path : /var/www/html/mtdc/common/components/ |
| Current File : /var/www/html/mtdc/common/components/HttpRequest.php |
<?php
namespace common\components;
use Yii;
use yii\base\Component;
use yii\base\Widget;
use yii\bootstrap\ButtonDropdown;
use yii\helpers\Url;
use yii\helpers\Html;
use yii\web\Cookie;
use backend\models\i18n\DmgI18nMessage;
class HttpRequest extends CHttpRequest {
public $noCsrfValidationRoutes = array();
protected function normalizeRequest() {
//attach event handlers for CSRFin the parent
parent::normalizeRequest();
//remove the event handler CSRF if this is a route we want skipped
if ($this->enableCsrfValidation) {
$url = Yii::app()->getUrlManager()->parseUrl($this);
foreach ($this->noCsrfValidationRoutes as $route) {
if (strpos($url, $route) === 0)
Yii::app()->detachEventHandler('onBeginRequest', array($this, 'validateCsrfToken'));
}
}
}
}