Actually, if you do not set $autoRedirect to false, you will never
reached the loginAction you defined.
If you want to be able to "cheat" the Auth and get the login method
handling empty($this->data), you have to set the the loginAction to
something else when in beforeFilter you detect the controller = 'User'
and action = 'login' ...

I did something like to "intercept" the loginAction and want to
control if in the User::login (callig Auth->login yourself):
..  in beforeFilter

if($this->action == 'login' && empty($this->data) && isset($this-
>Auth))
   $this->Auth->loginAction = '/users/logout';
hth

On Jul 3, 10:16 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> I was staring right at the problem! I had to set $autoRedirect = false
>
> hours later ...
>
> On Thu, Jul 3, 2008 at 3:31 PM, b logica <[EMAIL PROTECTED]> wrote:
> > I realise that my earlier post (re: isAuthorized) had a misleading
> > subject so I'm re-phrasing here.
>
> > I need to perform some stuff and add some info to the session upon
> > successful login. However, the login() method in UsersController seems
> > to be ignored completely. That is, it doesn't need to be present in
> > the controller unless making an initial GET request. What do I need to
> > do?
>
> > This is what I have in Users. When submitting the login form, this
> > method is never reached.
>
> > function login()
> > {
> >        if (!empty($this->data))
> >        {
> >                if ($this->Auth->login($this->data))
> >                {
> >                        $user = $this->Auth->user();
> >                        ...
> >                }
> >        }
> > }
>
> > AppController:
>
> > function beforeFilter()
> > {
> >        $this->Auth->fields = array('username' => 'email', 'password' => 
> > 'password');
> >        $this->Auth->authorize = null;
> >        $this->Auth->loginAction = array('controller' => 'users', 'action' 
> > => 'login');
> >        $this->Auth->logoutRedirect = '/';
> >        $this->Auth->autoRedirect = true;
> >        $this->Auth->userScope = array('User.enabled' => 1);
> >        $this->Auth->allow('setLang', 'enableComponent', 'enableElement',
> > 'disableElement', 'flash');
> > }
>
> > I had $authorize set to 'controller' but, AFAICT, that's unrelated.
> > I'm not looking to do any specific authorization routines. I just want
> > to check on the user and add some info to the session.
>
> > My next thought was to create a separate method and point
> > $loginRedirect to it in order to run my code, then add my own
> > redirection code to that. But that doesn't seem very efficient.
>
> > Or, was I correct in putting it in login() in the first place? If so,
> > why is it being ignored? The method doesn't even need to be present in
> > order to log in. I've been looking at the Auth.php but, frankly, I'm
> > pretty confused about what's going on inside startup(). I understood
> > it that, if a login method is present, then that will be run and a
> > call to $this->Auth->login($this->data) will take care of the loggin
> > in.
>
> > Perhaps this is just a question about components in general.
--~--~---------~--~----~------------~-------~--~----~
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