简体   繁体   中英

cakephp logout redirect

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

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.

我通过将注销重定向放在beforefilter中解决了这个问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM