Try debugging env('HTTP_REFERER') in addition to what Controller::referer($alt_redirect, true) gives you; your headers might be getting mangled for some reason or other. Also, is there a specific reason you are statically accessing the Controller::referer() method instead of using $this->referer() ?
-Joel. On May 22, 1:45 pm, "b logica" <[EMAIL PROTECTED]> wrote: > Suddenly, authentication for my app hasbecome completely unhinged. > This was working perfectly yesterday but now I'm (almost) always > redirected back to the login page. The only thing I've changed has to > do with $loginRedirect, but I can't see how that would cause Auth to > forget that I'm authenticated. > > My login() looks like (in part): > > /* I have 3 types of users who might log in. I need to create model > for each, rather than use roles, because > * their needs are quite different. So, I grab the model name from the > users table > */ > $model_name = $user['User']['model']; > $this->User->bindModel(array('hasOne'=>array($model_name=>array()))); > > /* This allows me to save a bit of personal info and set the default > redirect page if there's > * no referer. > */ > switch($model_name) > { > case 'Admin': > $name = > $this->User->Admin->getName($user['User']['foreign_key']); > $user['User']['name'] = $name['name']; > $alt_redirect = '/admin'; > break; > case 'Member': > $name_and_slug = > $this->User->Member->getNameAndSlug($user['User']['foreign_key']); > $user['User']['name'] = $name_and_slug['name']; > $user['User']['slug'] = $name_and_slug['slug']; > $alt_redirect = '/'; > break; > case 'Artist': > $name_and_slug = > $this->User->Artist->getNameAndSlug($user['User']['foreign_key']); > $user['User']['name'] = $name_and_slug['name']; > $user['User']['slug'] = $name_and_slug['slug']; > $alt_redirect = '/'; > break; > > } > > /* This is the only change made since yesterday. I added the > $alt_redirect so that admins will be sent > * to their dashboard page if there's no referer > */ > $this->Session->write('User', $user['User']); > $this->Auth->loginRedirect = Controller::referer($alt_redirect, true); > $this->redirect($this->Auth->redirect()); > > AppController::isAuthorised(): > > function isAuthorized() > { > if (isset($this->params[Configure::read('Routing.admin')])) > { > if ($this->Auth->user('model') != 'Admin') > { > $this->log('not ok: '.$this->Auth->user('model')); > return false; > } > } > > $this->log('ok'); > return true; > > } > > I put the log statements in just now to try to figure out what's going wrong. > > So, if I browse to: > /admin/artists/edit/58 > > I'm correctly redirected to the login page: > /admin/users/login > > and, in turn, redirected to the edit form and the log says, "ok". When > I hit submit, sometimes it works, and sometimes I'm sent back to the > login page. In the latter case, I never see the "not ok: Admin" in the > log. So, if the problem does not lie with isAuthorised() how/why am I > being redirected? --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---