diff --git a/controllers/SiteController.php b/controllers/SiteController.php index 785eddf..1196280 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -3,7 +3,9 @@ namespace app\controllers; use Yii; +use yii\web\AccessControl; use yii\web\Controller; +use yii\web\VerbFilter; use app\models\LoginForm; use app\models\ContactForm; @@ -13,7 +15,7 @@ class SiteController extends Controller { return array( 'access' => array( - 'class' => \yii\web\AccessControl::className(), + 'class' => AccessControl::className(), 'only' => array('login', 'logout'), 'rules' => array( array( @@ -28,6 +30,12 @@ class SiteController extends Controller ), ), ), + 'verbs' => array( + 'class' => VerbFilter::className(), + 'actions' => array( + 'logout' => array('post'), + ), + ), ); } diff --git a/views/layouts/main.php b/views/layouts/main.php index 240c2a3..1b7083d 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -36,7 +36,9 @@ app\config\AppAsset::register($this); array('label' => 'Contact', 'url' => array('/site/contact')), Yii::$app->user->isGuest ? array('label' => 'Login', 'url' => array('/site/login')) : - array('label' => 'Logout (' . Html::encode(Yii::$app->user->identity->username) .')' , 'url' => array('/site/logout')), + array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , + 'url' => array('/site/logout'), + 'linkOptions' => array('data-method' => 'post')), ), )); NavBar::end();