I want to set filter accessControll like that:
Only not-authentificated users can reach actions: captcha, register, recovery, activate;
Only authentificated users can reach actions: logout, settings;
How to set filter accessControl to do that?
I tried:
return array(
array('allow',
'actions'=>array('captcha','register','recovery', 'activate'),
'users'=>array('?'),
),
array('allow',
'actions'=>array('logout','settings'),
'users'=>array('@'),
),
array('allow',
'actions'=>array('login'),
'users'=>array('*'),
),
array('deny',
'actions'=>array('*'),
'users'=>array('*'),
),
);
and:
return array(
array('deny',
'actions'=>array('captcha','register','recovery', 'activate'),
'users'=>array('@'),
),
array('allow',
'actions'=>array('logout','settings'),
'users'=>array('@'),
),
array('allow',
'actions'=>array('login'),
'users'=>array('*'),
),
array('deny',
'actions'=>array('*'),
'users'=>array('*'),
),
);
First example doesn’t work.
In second one I saw strange behaviour…
Even I have configured errorAction in main.php Yii was trying to reach default errorAction, stack:
#0 E:\PHP\kodinocms\yii\web\CController.php(262): CController->missingAction(‘error’)
#1 E:\PHP\kodinocms\yii\web\CWebApplication.php(328): CController->run(‘error’)
#2 E:\PHP\kodinocms\yii\base\CErrorHandler.php(279): CWebApplication->runController(’/site/index/err…’)
#3 E:\PHP\kodinocms\yii\base\CErrorHandler.php(178): CErrorHandler->render(‘error’, Array)
#4 E:\PHP\kodinocms\yii\base\CErrorHandler.php(103): CErrorHandler->handleException(Object(CHttpException))
#5 E:\PHP\kodinocms\yii\base\CApplication.php(631): CErrorHandler->handle(Object(CExceptionEvent))
#6 [internal function]: CApplication::handleException(Object(CHttpException))
#7 {main}
I don’t understand it.
Any advices? Or should I do it manually by checking Yii::app()->user->isGuest in every action?