Answer the question
In order to leave comments, you need to log in
Error when using access control filter what did I do wrong?
Filter controller
<?
namespace app\controllers;
use yii;
use yii\web\Controller;
use yii\filters\AccessControl;
class BehaviorsController extends Controller
{
public function behaviors()
{
return
[
'access' => [
'class' => AccessControl::className(),
'rules' =>[
[
'allow' => true,
'controllers' => ['SiteController'],
'actions' => ['reg', 'login'],
'verbs' => ['GET', 'POST'],
'roles' => ['?']
],
]
]
]
];
}
}
The SiteController itself
<?php
namespace app\controllers;
use yii;
use app\models\LoginForm;
use app\models\RegForm;
use app\models\User;
class SiteController extends BehaviorsController
{
/**
* Displays homepage.
*
* return string
*/
public function actionIndex()
{
return $this->render('index');
}
/**
* Logout action.
*
* return string
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
}
error:
Answer the question
In order to leave comments, you need to log in
Your request does not get into the controller, I didn’t really read the code, since the error is visible before it. Check config.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question