Redirect if not logged Auth CakePHP

1

I have a small question.

I configured the beforeFilter correctly to allow access to the actions due.

My question is the following. When I try to access a certain action in a particular controller, the application is directing me to ... admin / login, where I would login, but the correct one would be for login / index.

Where do I set up this redirect so that unregistered users are redirected to "login / index"?

I imagine something here in this file. If anyone can help me, I'll be grateful.

AppController.php:

App::uses('Controller', 'Controller');

    class AppController extends Controller {

        public $components = array(

            "Session",
            "Auth" => array(

                'loginRedirect' => array('controller' => 'imagens'),
                'logoutRedirect' => array('controller' => 'login'),
                'authError' => "Você não pode acessar essa página",
                "authorize" => array('Controller'),
                'authenticate' => array(
                    'all' => array(
                        'userModel' => 'Login'
                    ),
                    'Form' => array(
                        'fields' => array(
                          'username' => 'username', //Default is 'username' in the userModel
                          'password' => 'password'  //Default is 'password' in the userModel
                        )
                    )
                ),

            )

        );

        public function isAuthorized($login){
            return true;
        }

        public function beforeFilter(){
            if(!isset($_SESSION)) session_start();
            $this->Auth->allow('index');
            $this->set('logged_in', $this->Auth->loggedIn());
            $this->set('current_user', $this->Auth->user());
        }

    }
    
asked by anonymous 20.04.2015 / 17:03

0 answers