Redirect Loop Cakephp

Asked

Viewed 74 times

1

I’m maintaining a cakephp system but trying to log in to Brower returns the following error.

This webpage has a loop redirect

I searched the stack em ingles and found a "solution" that told me to include:

$this->Auth->allow('display');

In my class AppController within the facility beforeFilter(), This worked but now when soon in the system no menu link works. Below the code of 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 method of login:

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');
    }

1 answer

0

Are you declaring LoginRedirect twice, try to take one, I suggest the with the way 'pages' => 'login';

'loginRedirect' => array('controller' => 'eventos', 'action' => 'index'),
        'loginRedirect' => array('controller' => 'pages', 'action' => 'login'),

to direct the user to login page as soon as they access the root of your system use $this->Auth->loginAction();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.