How can I redirect the user whe he is not authorized to perform the action?
On some cases he will se the error page others he will see this
CHttpException
You are not authorized to perform this action. (E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\web\auth\CAccessControlFilter.php:153)
#0 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\web\auth\CAccessControlFilter.php(115): CAccessControlFilter->accessDenied(Object(WebUser), 'You are not aut...')
#1 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\web\filters\CFilter.php(39): CAccessControlFilter->preFilter(Object(CFilterChain))
#2 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\web\CController.php(999): CFilter->filter(Object(CFilterChain))
#3 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#4 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain))
#5 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\web\CController.php(283): CFilterChain->run()
#6 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\web\CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#7 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\web\CWebApplication.php(320): CController->run('error')
#8 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\base\CErrorHandler.php(235): CWebApplication->runController('site/error')
#9 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\base\CErrorHandler.php(153): CErrorHandler->render('error', Array)
#10 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\base\CErrorHandler.php(96): CErrorHandler->handleException(Object(CHttpException))
#11 E:\Users\thiagovidal\Development\xampp\htdocs\yii\framework\base\CApplication.php(581): CErrorHandler->handle(Object(CExceptionEvent))
#12 [internal function]: CApplication->handleException(Object(CHttpException))
#13 {main}
how can i redirect him to another page?
Page 1 of 1
Redirect User on not authorized
#2
Posted 24 June 2010 - 11:39 AM
CAccessControlFilter throws CHttpException with error code "403" when an access is denied. If your errorHandler is configured that errorAction is "site/index", then you can modify SiteController as follows:
class SiteController extends CController
{
...
public function actionError()
{
if (Yii::app()->errorHandler->error['code'] == 403)
$this->redirect('url');
else
$this->render('error');
}
...
}
#4
Posted 24 June 2010 - 04:26 PM
Did you add to your config file next strings?
It works for me.
'components'=>array(
...
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
...
),
It works for me.
Share this topic:
Page 1 of 1

Help














