abedi98
(Abedi98)
October 10, 2012, 12:08pm
1
hi freinds
look at please :
this is MainController :
public function filters()
{
return array(
'accessControl'
);
}
public function accessRules()
{
return array(
array('deny',
'users'=>array('demo','abedi98'),
),
);
}
when use it this code :
array('deny',
'users'=>array('demo','abedi98'),
),
run this url : http://localhost/yii/index.php?r=main/index
CHttpException
You are not authorized to perform this action. (D:\xampp\htdocs\yiiframework\framework\web\auth\CAccessControlFilter.php:157)
#0 D:\xampp\htdocs\yiiframework\framework\web\auth\CAccessControlFilter.php(120): CAccessControlFilter->accessDenied(Object(WebUser), ‘You are not aut…’)
#1 D:\xampp\htdocs\yiiframework\framework\web\filters\CFilter.php(39): CAccessControlFilter->preFilter(Object(CFilterChain))
#2 D:\xampp\htdocs\yiiframework\framework\web\CController.php(1146): CFilter->filter(Object(CFilterChain))
#3 D:\xampp\htdocs\yiiframework\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#4 D:\xampp\htdocs\yiiframework\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter(Object(CFilterChain))
#5 D:\xampp\htdocs\yiiframework\framework\web\CController.php(292): CFilterChain->run()
#6 D:\xampp\htdocs\yiiframework\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
#7 D:\xampp\htdocs\yiiframework\framework\web\CWebApplication.php(276): CController->run(‘error’)
#8 D:\xampp\htdocs\yiiframework\framework\base\CErrorHandler.php(310): CWebApplication->runController(‘main/error’)
#9 D:\xampp\htdocs\yiiframework\framework\base\CErrorHandler.php(183): CErrorHandler->render(‘error’, Array)
#10 D:\xampp\htdocs\yiiframework\framework\base\CErrorHandler.php(108): CErrorHandler->handleException(Object(CHttpException))
#11 D:\xampp\htdocs\yiiframework\framework\base\CApplication.php(713): CErrorHandler->handle(Object(CExceptionEvent))
#12 [internal function]: CApplication->handleException(Object(CHttpException))
#13 {main}
zaccaria
(Matteo Falsitta)
October 10, 2012, 12:41pm
2
Have you set error action? Does error action works properly?
abedi98
(Abedi98)
October 10, 2012, 2:40pm
3
YES.
public function actionError()
{
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('back/error', $error);
}
}
abedi98
(Abedi98)
October 10, 2012, 2:45pm
4
if set actions value in array
array('deny',
'actions'=>array('index'),
'users'=>array('demo','abedi98'),
),
Right and wrong does not, But I do not want use ‘actions’
mickey85
(Miralem)
March 9, 2013, 1:50pm
5
add the error action to accessRules
public function accessRules()
{
return array(
array(
'allow',
'actions' => array('login', 'logout', 'error'),
'users' => array('*'),
),
);
}