Answer the question
In order to leave comments, you need to log in
RBAC in Yii2: Exeption is displayed as plain text, without decoration. How to fix?
Made rbac according to this article https://habrahabr.ru/post/235485/.
There are 2 ways to check access.
When I do it in the 1st way: at the beginning of each action I write
if (!\Yii::$app->user->can('about')) {
throw new ForbiddenHttpException('Access denied');
public function beforeAction($action)
{
if (parent::beforeAction($action)) {
if (!\Yii::$app->user->can($action->id)) {
throw new ForbiddenHttpException('Access denied');
}
return true;
} else {
return false;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question