0
votes

I'm using ACL and Auth in my application.

If a logged-out user loads an internal bookmarked page to the site (other than home), Cake correctly prompts for login. However, once logged in, it redirects to the url that the user was trying to access prior to login.

I need to have the user redirected to pages/home after login, regardless of the url that they were trying to access.

So far, I haven't found that $this->Auth command to accomplish this. Any ideas?

Here is the auth code from app_controller.php

    function beforeFilter() {
    //Configure AuthComponent
    //$this->Auth->allow(array('*'));
    $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
    $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
    $this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'home');
    $this->Auth->actionPath = 'controllers/';

Thanks for any thoughts

1

1 Answers

1
votes

Make sure to include the following in your beforeFilter function:

function beforeFilter() {
    $this->Auth->autoRedirect = false;
    parent::beforeFilter();
}

Also be sure that you don't have something like this in your login function:

$this->redirect($this->Auth->redirect());

Auth->redirect() returns the url where the user landed before being taken to the login page or Auth->loginRedirect.

You should be able to redirect to wherever you want, either using a $this->redirect in your login function or by setting the default Login redirect.