Sarower Jahan
Sarower Jahan

Reputation: 1495

How do I fix the error "Did you really think you are allowed to see that"

I am fresher in cakephp. For my current project, I am using CakePHP skeleton app. Everything going fine. But when I am creating new controller for admin panel then it showing this message Did you really think you are allowed to see that?. Someone please help me.

I am showing my codes below:

Route:

Router::prefix('admin', function ($routes) {
     // Other routes are here.
     $routes->connect('/sections', ['controller' => 'Sections', 'action' =>'index']);
}

SectionsController.php

<?php

namespace App\Controller\Admin;

    use App\Controller\AppController;

    class SectionsController extends AppController {

    public function index() {
        echo "I am for sections page";
    }

}

This controller is locate in src\Controller\Admin folder

Below is my error message.

enter image description here

Upvotes: 0

Views: 205

Answers (1)

Mustafa
Mustafa

Reputation: 339

probably this would be the solution.

use Cake\Event\Event;
class YourController extends AppController
{
     public function beforeFilter(Event $event)
     {
         parent::beforeFilter($event);        
         $this->Auth->allow('index');
     }
}

Upvotes: 3

Related Questions