cakephp - auth注销重定向

ger*_*erl 0 authentication redirect login logout cakephp-2.0

在cakephp2.0中,我有domain.com但是当我退出(url是domain.com/logout)时,它被重定向到domain.com/app/login.我不希望它重定向到domain.com/app/login,而是重定向到domain.com/logout.这些是我在UsersController和AppController中的代码

class AppController extends Controller {
public $helpers = array ('Html', 'Form', 'Js' => array('Jquery'), 'Session');

public $components = array(
    'Session',
    'Auth' => array(
        'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
        'logoutRedirect' => array('controller' => 'users', 'action' => 'login'),
         'authorize' => array('Controller') // Added this line
    )
);
}
Run Code Online (Sandbox Code Playgroud)

Userscontroller

class UsersController extends AppController {
public $components = array(

    'Auth' => array(
        'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
        'logoutRedirect' => array('controller' => 'users', 'action' => 'login'),
         'authorize' => array('Controller') // Added this line
    )
);

public function beforeFilter() {
    parent::beforeFilter();
    $this->Auth->allow('add', 'logout', 'login');
    $this->Auth->deny('view');
}

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

            $this->redirect('http://domain.com/thankyou');
        } else {
            $this->Session->setFlash(__('Invalid username or password, try again'));
        }
    }
}

public function logout() {
    $this->redirect($this->Auth->logout());
}
}
Run Code Online (Sandbox Code Playgroud)

任何帮助都会很棒.谢谢.

ger*_*erl 5

我最终在我的logout()函数中使用它

$this->Auth->logout();
$this->redirect(some url);
Run Code Online (Sandbox Code Playgroud)