1
I’m having a little doubt.
I set the beforeFilter correctly to allow access to the appropriate actions.
My question is this. When I try to access a certain action in a given controller, the application is directing me to ...admin/login, where I would log in, but the correct one would be for login/index.
Where do I set this redirect so that non-logged users are redirected to "login/index"?
I imagine it’s 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()); } }
Take a look at this link, it has a logout method: http://pastebin.com/RmZLhDRG
– david