samilo
(Samiloxphp)
October 31, 2012, 10:35am
1
[b]Hi All
In access roles when you deny users to access to actions , then if user open deny action message will be like that :[/b]
[b]CHttpException[/b]
You are not authorized to perform this action. (H:\xampp\htdocs\yii\framework\web\auth\CAccessControlFilter.php:170)
#0 H:\xampp\htdocs\yii\framework\web\auth\CAccessControlFilter.php(133): CAccessControlFilter->accessDenied(Object(CWebUser), 'You are not aut...') #1 H:\xampp\htdocs\yii\framework\web\filters\CFilter.php(39): CAccessControlFilter->preFilter(Object(CFilterChain)) #2 H:\xampp\htdocs\yii\framework\web\CController.php(1146): CFilter->filter(Object(CFilterChain)) #3 H:\xampp\htdocs\yii\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain)) #4 H:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter(Object(CFilterChain)) #5 H:\xampp\htdocs\yii\framework\web\CController.php(292): CFilterChain->run() #6 H:\xampp\htdocs\yii\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array) #7 H:\xampp\htdocs\yii\framework\web\CWebApplication.php(283): CController->run('error') #8 H:\xampp\htdocs\yii\framework\base\CErrorHandler.php(332): CWebApplication->runController('site/error') #9 H:\xampp\htdocs\yii\framework\base\CErrorHandler.php(205): CErrorHandler->render('error', Array) #10 H:\xampp\htdocs\yii\framework\base\CErrorHandler.php(130): CErrorHandler->handleException(Object(CHttpException)) #11 H:\xampp\htdocs\yii\framework\base\CApplication.php(713): CErrorHandler->handle(Object(CExceptionEvent)) #12 [internal function]: CApplication->handleException(Object(CHttpException)) #13 {main}
[b]How To customize it to print just Error message like :
You are not authorized to perform this action
Thanks in advance [/b]
konapaz
(Konapaz)
October 31, 2012, 11:45am
2
samilo:
[b]Hi All
In access roles when you deny users to access to actions , then if user open deny action message will be like that :[/b]
[b]CHttpException[/b]
You are not authorized to perform this action. (H:\xampp\htdocs\yii\framework\web\auth\CAccessControlFilter.php:170)
#0 H:\xampp\htdocs\yii\framework\web\auth\CAccessControlFilter.php(133): CAccessControlFilter->accessDenied(Object(CWebUser), 'You are not aut...') #1 H:\xampp\htdocs\yii\framework\web\filters\CFilter.php(39): CAccessControlFilter->preFilter(Object(CFilterChain)) #2 H:\xampp\htdocs\yii\framework\web\CController.php(1146): CFilter->filter(Object(CFilterChain)) #3 H:\xampp\htdocs\yii\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain)) #4 H:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter(Object(CFilterChain)) #5 H:\xampp\htdocs\yii\framework\web\CController.php(292): CFilterChain->run() #6 H:\xampp\htdocs\yii\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array) #7 H:\xampp\htdocs\yii\framework\web\CWebApplication.php(283): CController->run('error') #8 H:\xampp\htdocs\yii\framework\base\CErrorHandler.php(332): CWebApplication->runController('site/error') #9 H:\xampp\htdocs\yii\framework\base\CErrorHandler.php(205): CErrorHandler->render('error', Array) #10 H:\xampp\htdocs\yii\framework\base\CErrorHandler.php(130): CErrorHandler->handleException(Object(CHttpException)) #11 H:\xampp\htdocs\yii\framework\base\CApplication.php(713): CErrorHandler->handle(Object(CExceptionEvent)) #12 [internal function]: CApplication->handleException(Object(CHttpException)) #13 {main}
[b]How To customize it to print just Error message like :
You are not authorized to perform this action
Thanks in advance [/b]
Hi samilo
You could set ‘message’=>‘you message Access Denied.’, on accessRules function like that (I think)
public function accessRules()
{
array('deny', // deny all users
'users'=>array('*'),
'message'=>'you message Access Denied.',
),
samilo
(Samiloxphp)
October 31, 2012, 12:39pm
3
Hi Konapaz and thank you , I try it but Not work
abennouna
(Abennouna)
October 31, 2012, 1:06pm
4
It seems you are in debug mode. Just comment out the relevant line in your webroot/index.php
samilo
(Samiloxphp)
October 31, 2012, 1:32pm
5
Hi bennouna ,
yes I am in debug mode , is possible to customize error message ?
I return to normal mode and i added :
public function accessRules()
{
array('deny', // deny all users
'users'=>array('*'),
'message'=>'you message Access Denied.',
),
But Also Not worked !
konapaz
(Konapaz)
November 1, 2012, 8:04am
6
samilo:
Hi bennouna ,
yes I am in debug mode , is possible to customize error message ?
I return to normal mode and i added :
public function accessRules()
{
array('deny', // deny all users
'users'=>array('*'),
'message'=>'you message Access Denied.',
),
But Also Not worked !
Hi Samil,
I just tested and it works exactly you has wrote.
Is any message appeared on your site?
If redirect take place then you do not see any error message
both debug and productive mode for this type of messages sould be appeared.
Is the code of error message 403? You sould see Error 403
I think the best way to solve this is by using the SRBAC
deli6z
(Deli6z)
December 2, 2012, 11:38pm
8
is there a way to customize not just the message itselt but the way how page is rendered. For example for controllers errors errors can be customized in actionError method but for my error message (it’s user rigths denied) it’s not even getting into actionError method of the corresponding controller