Monday, September 29, 2008

Re: Auth Redirect Problems

LunarDraco wrote:
>
>
> Here are the changes I made
> Auth.php
> at about line 300 look for this:
> if ($loginAction == $url) {
> if (empty($controller->data) || !isset($controller->data[$this-
>>userModel])) {
> if (!$this->Session->check('Auth.redirect') &&
> env('HTTP_REFERER')) {
> $this->log('302 session.write auth.redirect '.$url);
> $this->log('Controller->referer()'.$controller->referer());
> $this->Session->write('Auth.redirect', $controller->referer());
> }
> return false;
> }
> -----
> Change to:
> -----
> if ($loginAction == $url) {
> if (empty($controller->data) || !isset($controller->data[$this-
>>userModel])) {
> if (!$this->Session->check('Auth.redirect') && env('HTTP_REFERER')
> && !$this->Session->check('Auth.loggedout')) {
> $this->log('302 session.write auth.redirect '.$url);
> $this->log('Controller->referer()'.$controller->referer());
> $this->Session->write('Auth.redirect', $controller->referer());
> }
> return false;
> }
> -----
>
> Then change the auth logout function to look like:
> function logout() {
> $this->__setDefaults();
> $this->Session->del($this->sessionKey);
> $this->Session->del('Auth.redirect');
> $this->Session->write('Auth.loggedout',true);
> $this->_loggedIn = false;
> return Router::normalize($this->logoutRedirect);
> }
>
>
> I hope this is helpful to everyone. I've spent a better part of a day
> chasing this little bugger.
>
>

Definitely helpful. Thanks! I was working on the same problem on Friday and
was pretty much heading towards the same solution. I have made a slight
change though which is to add these auth.php alterations to an extended
AuthComponent class. This means no core hacks are required but since I had
already extended AuthComponent in the past for other reasons there was no
overhead involved with changing the rest of my site's code.
--
View this message in context: http://n2.nabble.com/Auth-Redirect-Problems-tp1078183p1125460.html
Sent from the CakePHP mailing list archive at Nabble.com.


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

No comments: