On Wed, Sep 15, 2010 at 6:03 PM, Jeremy Burns | Class Outfit
<[email protected]> wrote:
> Speculation... but would $this->referer() help?

That's what I first thought, as it's what Auth::startup() uses:

$controller->redirect($controller->referer(), null, true);

What I did was log out, then click on a known protected URL,
'/resources', which redirects me to login. In my login() method, just
before it redirects, I have: die(debug($this->referer)); and I get
"/login".

If I comment out the die(), I do get redirected to /resources.

Auth::autoRedirect is false, btw.

UPDATE: OK, I just clued in and looked at the redirect() method. I
need to check Session's 'Auth.redirect' key. This is what I ended up
with. This seems to work, although I'm not certain it's the best
strategy.

$redirect = $this->Session->read('Auth.redirect');

$blacklist = array(
        array('controller' => 'transactions', 'action' => 'hpp'),
        array('controller' => 'transactions', 'action' => 'cancel')
        // any other routes
);

if (!empty($redirect))
{
        foreach ($blacklist as $route)
        {
                if (Router::url($route) == $redirect)
                {
                        $this->redirect($this->Auth->loginRedirect);
                }
        }
}

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


So, if the redirect in the Session is in the blacklist, the controller
redirects to the default route for Auth. If not, the controller
redirects through Auth's method.

As for automatically logging a user in, I'm still unsure what I'm
supposed to pass to Auth::login().

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to