This is driving me nuts. What am i doing wrong here?
No matter what I put for access rules they are seemingly ignored and I can access every page/action.
Here is my SiteController.php
<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\LoginForm;
use app\models\Ticket;
use app\models\Product;
class SiteController extends Controller
{
public function filters()
{
return array('accessControl');
}
public function accessRules()
{
return array(
array('deny',
'actions'=>array('index'),
),
);
}
public function beforeAction($action)
{
if (!Yii::$app->user->isGuest)
{
if (!Yii::$app->user->identity->gotCwData)
{
Yii::$app->user->identity->getCwData();
}
Yii::$app->user->identity->openTickets = Ticket::getTicketCount();
}
return true;
}
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex()
{
/*if(Yii::$app->user->isGuest && Yii::$app->controller->action->id != "login") {
Yii::$app->user->loginRequired();
$this->actionLogin();
return true;
}*/
$agreements = Product::getAgreementList();
$tickets = Ticket::getTickets();
return $this->render('index', [
'agreements' => $agreements,
'tickets' => $tickets,
]);
}
/**
* Login action.
*
* @return string
*/
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
}
return $this->render('login', [
'model' => $model,
]);
}
/**
* Logout action.
*
* @return string
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
}