On Wed, Jun 30, 2010 at 6:27 AM, [email protected]
<[email protected]> wrote:
> Hi
>
> I have configured the Auth component and its working fine. I need to
> save a User associated model in the session.
> I assume the best way to do this is to catch the successful login and
> then add the associated model to the session.
> I have set Auth->loginAction = users/login. Auth->login is called in
> the Auth->startup method and never calls users/login.

AppController::beforeFilter()
        
$this->Auth->loginAction = array(
        'controller' => 'users',
        'action' => 'login'
);
$this->Auth->loginRedirect = array(
        // somewhere you want users to go after login
);

/* tell Cake that you want to do something in login() before redirecting
 */
$this->Auth->autoRedirect = false;
        

UsersController:
public function login()
{
        if (!empty($this->data) && $user = $this->Auth->user())
        {
                /* do what you need to do ...
                 */
                
                $this->redirect($this->Auth->redirect());
        }
}

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