0
votes

I have a cakephp app that when I logout it add's admin/login ti the url of the logging in screen. Then when I log in again it says missing controler. I already have a redirect to the Auth logout. If I change that will it still logout?

Original login url:

mydomain.com/res/admin

Url after logout

mydomain.com/res/admin/users/login

After I log in to admin:

mydomain.com/res/admin/admin/login

user controller:

function admin_logout() {
    $this->redirect($this->Auth->logout());
}
2
From what I understand you set the custom auth settings in a controller with the beforeFilter(). I have $this->Auth->allowedActions = array('admin_login','admin_logout'); Is there other settings? - Keith Power
Please provide the relevant configuration of the Auth component, and your routes. - Ivo

2 Answers

1
votes

In AppController you can do something like this

public $components = array(
        'Session',
        'Auth' => array(
        'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
        'logoutRedirect' => array('controller' => 'users', 'action' => 'login', 'login'),//redirect url
        'authorize' => array('Controller')
    )

);

and in UserController

public function logout() {
        $this->redirect($this->Auth->logout());

}

this worked for me.

-1
votes

I solved this by putting a logout redirect in the beforefilter.