I am performing maintenance on a system made with cakephp however when trying to log in the browser returns the following error.
This webpage has a redirect loop
I looked at stack em ingles
and found a "solution" that said to include:
$this->Auth->allow('display');
In my class AppController
within method beforeFilter()
, this worked but now when in the system no menu link works.
Below the code for AppController
public $components = array(
'Session',
'RequestHandler',
'Auth'=>array(
'loginRedirect' => array('controller' => 'eventos', 'action' => 'index'),
'loginRedirect' => array('controller' => 'pages', 'action' => 'login'),
'logoutRedirect' => array('controller' => 'user', 'action' => 'login'),
'authorize' => array('Controller'),
'authError' => 'Você não tem permissão para acessar essa área!'
));
public $helpers = array('Html', 'Form', 'Session', 'Time', 'Text', 'Number');
public $model;
public $not_condition = array('page', 'direction', 'sort');
public $filter_with_like = array();
public $conditions = array();
public $limit = 20;
public function beforeFilter() {
//$this->Auth->allow('display');
$this->Auth->authError = 'Área restrita';
$this->Auth->authorize = 'Controller';
$this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'index' );
}
The login method:
public function login() {
$this->layout = 'login';
$this->Session->destroy();
if ($this->request->is('post')) {
$this->User->Behaviors->load('Containable');
$this->User->recursive = -1;
if ($this->Auth->login($this)) {
$user = $this->User->checkIn($this->request->data['User']['user'], $this->request->data['User']['senha']); //Checa user e senha
if ($user != false) { // Se tiver tudo ok
$user['Admin'] = $user['User'];
$this->Auth->login($user['User']);
$this->Auth->login();
$this->Session->read();
$this->Session->write($this->Auth->sessionKey, $this->Auth->user());
//$this->redirect($this->Auth->redirect('/' . $th is->Auth->user('Nivel.short') . '/dashboard/'));
$this->redirect($this->Auth->redirect(array('controller' => 'email', 'action' => 'relatorio')));
} else {
$this->Session->setFlash('Dados incorretos', 'login');
}
} else
$this->Session->setFlash('Dados incorretos', 'login');
}