A
A
Alexander2015-10-08 16:07:27
Yii
Alexander, 2015-10-08 16:07:27

What is the ForbiddenHttpException error?

SiteController

public function beforeAction(){
        if(Yii::$app->user->can('admin')){
            return true;
        } else {
            throw new ForbiddenHttpException;
        }
    }

Site error:
An Error occurred while handling another error:
exception 'yii\web\NotFoundHttpException' with message 'The requested page does not exist.' in A:\my_projects\advanced.local\www\backend\controllers\SiteController.php:62
Stack trace:
#0 A:\my_projects\advanced.local\www\vendor\yiisoft\yii2\base\Controller.php(149): backend\controllers\SiteController->beforeAction(Object(yii\web\ErrorAction))
#1 A:\my_projects\advanced.local\www\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('error', Array)
#2 A:\my_projects\advanced.local\www\vendor\yiisoft\yii2\web\ErrorHandler.php(85): yii\base\Module->runAction('site/error')
#3 A:\my_projects\advanced.local\www\vendor\yiisoft\yii2\base\ErrorHandler.php(109): yii\web\ErrorHandler->renderException(Object(yii\web\NotFoundHttpException))
#4 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\NotFoundHttpException))
#5 {main}
Previous exception:
exception 'yii\web\NotFoundHttpException' with message 'The requested page does not exist.' in A:\my_projects\advanced.local\www\backend\controllers\SiteController.php:62
Stack trace:
#0 A:\my_projects\advanced.local\www\vendor\yiisoft\yii2\base\Controller.php(149): backend\controllers\SiteController->beforeAction(Object(yii\base\InlineAction))
#1 A:\my_projects\advanced.local\www\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('', Array)
#2 A:\my_projects\advanced.local\www\vendor\yiisoft\yii2\web\Application.php(84): yii\base\Module->runAction('site', Array)
#3 A:\my_projects\advanced.local\www\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#4 A:\my_projects\advanced.local\www\backend\web\index.php(18): yii\base\Application->run()
#5 {main

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2015-10-08
@webinar

He writes to you that he did not find the page in SiteController.php on line 62. Probably the wrong view address. What do you have in SiteController.php on line 62? Why did you post beforeAction()? The error is not in it.

A
Alexander, 2015-10-09
@p0vidl0

In this case, this is not an error. A ForbiddenHttpException is thrown if the current user does not have administrator rights. Get familiar with RBAC .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question