0

I have implemented a set of rules but when a user attempts to access a restricted area, I am getting a text output instead of a nice boostrap alert. How can I get this working again?

Rule:

public function behaviors()
{
    return [
        'access' => [
            'class' => AccessControl::className(),
            'only' => ['index', 'view'],
            'rules' => [
                [
                    'roles' => ['@'],
                    'actions' => ['index', 'view'],
                    'allow' => true,
                ],
            ],
        ],

Exception message:

An Error occurred while handling another error:
exception 'yii\web\ForbiddenHttpException' with message 'You are not allowed to perform this action!.' in ###\vendor\yiisoft\yii2\filters\AccessControl.php:151
Stack trace:...
DrBorrow
  • 950
  • 12
  • 24
  • Switch environment `'YII_ENV'` to production. – Bizley Oct 20 '16 at 18:34
  • I tried that and I get a message "internal server error" and an otherwise blank page. This was all working before so not sure what I have done. (PS: to switch to production I commented out the dev in web/index.php - I presume this is correct). – DrBorrow Oct 20 '16 at 18:39
  • Right. Check the runtime `app.log`, there is some other error thrown here. Maybe there is no `ErrorAction` defined? – Bizley Oct 20 '16 at 18:41
  • Thanks. The errorhandler is defined (site/error), the site/error page exists and the runtime log says exactly what the on-screen error says. Identical. I am using the dektrium addon but this was all working so I know it is something i have done... probably in the rules or something – DrBorrow Oct 20 '16 at 19:07
  • solved... thanks for the help. I will answer the question - your guidance made me think and I found what I did! – DrBorrow Oct 20 '16 at 19:11

1 Answers1

0

Thanks Bizley for your help. I followed your instructions and discovered that I rather stupidly copied my rules to my site/error page meaning that I accidentally blocked the ability to see the error page!!! I removed the offending rule and all is working.

DrBorrow
  • 950
  • 12
  • 24