CakePHP 2.5.2 URL includes application path twice after authentication

I created a simple website and added authentication using the ACL guides found here . I think I followed this letter.

I have a question:
After logging in, if I try to access a valid URL, the route folder will be added again. e.g. Access:

 projectpath/controllerpath/action

redirected to

 projectpath/projectpath/controllerpath/action

Those things that I noticed:

  • This only happens if the user is logged in. If they are not logged in, they are redirected correctly to the login page.
  • Only on pages that have controllers does this happen. If I put the wrong page, it throws a Missing Controller Exception.
  • , , . , .

Edit:

CakePHP 2.5.3. , . - .

, ?

Edit: . ACL Auth.

, , , URL-.

AuthComponent::$unauthorizedRedirect . URL- AuthComponent:: $loginAction '/. false, ForbiddenException .

App Controller

    public $components = array(
    'DebugKit.Toolbar',
    'Auth' => array(
        'redirectUrl' => array(
            'controller' => 'pages',
            'action' => 'index'
        ),
        'logoutRedirect' => array(
            'controller' => 'user',
            'action' => 'login',
            'home'
        ),
        'authenticate' => array(
            'Form' => array(
                'passwordHasher' => 'Blowfish'
            )
        ),
        'unauthorizedRedirect'=> false,// I have added this line
    'Session',
     'authorize' => array('Controller') 
    )
);

( ). - , ?

Edit beforeFilter App Controller

public function beforeFilter() {

    $this->Auth->allow('display');
    /*if($this->Auth->user('role') == 'apa'){

    $this->Auth->redirectUrl = "/apa";
    }else{
    $this->Auth->redirectUrl = "/test";
    }*/ //Moved logic to UserController
        parent::beforeFilter();
}

UserController

public function login() {
    if ($this->request->is('post')) {
        if ($this->Auth->login()) {
            if($this->Auth->user('role') == 'apa'){

            $this->Auth->redirectUrl = "/apa";
                }else{
            $this->Auth->redirectUrl = "/test";
            }

            return $this->redirect($this->Auth->redirectUrl);
        }

        $this->Session->setFlash(__('Invalid username or password, try again'));
    }
}
+4
1

loginAction loginRedirect AuthComponent, :

'Auth' => array(
    'loginAction' => array('admin' => false, 'controller' => 'users', 'action' => 'login'),
    'loginRedirect' => array('admin' => false, 'controller' => 'pages', 'action' => 'index'),    // redirected here after login success
    'logoutRedirect' => array(
        'controller' => 'user',
        'action' => 'login',
        'home'
    ),
    'authenticate' => array(
        'Form' => array(
            'passwordHasher' => 'Blowfish'
        )
    ), ...

, AuthComponent:: redirectUrl - , , v2.3.

: http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html

0

All Articles