Hello,

I hava a similar problem, From mi actual code I extract this sample adjust
the Session content whenever I need more nformation, for example:

1 ) Set

class AppController extends Controller {

   function beforeFilter() {
      ...
      $this->Auth->redirect = false;
      ...
   }

}

2) In UserController::login() include

class  UserController extends AppController {

   function login() {
      if (!$this->data) {
         $id = $this->Auth->user('id');
         if ($id) { // Success login
            $this->__adjustSessionInfo($id);
            ...
         }
      }
   }


   function __adjustSessionInfo($id) {
        $this->User->contain(array('Group', 'Profile'));
        $user = $this->User->read(null, $id);
        $session = $this->Auth->user();
        $session['User']['id'] = $id;
        if (array_key_exists('Profile', $user)) {
            if (isset($user['Profile']['first_name'])) {
                $session['User']['first_name'] =
$user['Profile']['first_name'];
            }
            if (isset($user['profile']['father_last_name'])) {
                $session['User']['father_last_name'] =
$user['Profile']['father_last_name'];
            }
            if (isset($user['Profile']['mother_last_name'])) {
                $session['User']['mother_last_name'] =
$user['Profile]['mother_last_name'];
            }
        } else {
            $session['User']['first_name'] = $session['User']['username'];
            $session['User']['father_last_name'] = 'User';
        }
        $session['User']['name'] = '';
        $sep = '';
        if (isset($session['User']['first_name'])) {
            $session['User']['name'] .= $sep.$session['User']['first_name'];
            $sep = ' ';
        }
        if (isset($session['User']['father_last_name'])) {
            $session['User']['name'] .=
$sep.$session['User']['father_last_name'];
            $sep = ' ';
        };
        if (isset($session['User']['mother_last_name'])) {
            $session['User']['name'] .=
$sep.$session['User']['mother_last_name'];
            $sep = ' ';
        }
        $session['User']['is_super'] = $user['Group']['is_super'];
        $session['User']['group'] = $user['Group']['title'];
        $this->Session->del($this->Auth->sessionKey);
        $session = $session['User'];
        $this->Session->write($this->Auth->sessionKey, $session);
   }
}

In above code I added Profile and Group info to Session.

Later on     $this->Auth->user($key)    will return any $key stored by
__adjustSesison() function besides the ones stored by Auth itself.
You may also delete any non wanted key.

Regards.



2009/3/10 Sergei <[email protected]>

>
> You have to do it by hands, using find() and beforeAction() on some
> actions where you need profile info. Auth doesn't get related data.
>
> On 11 мар, 05:47, "Dave Maharaj :: WidePixels.com"
> <[email protected]> wrote:
> > Does anyone know how to get user variables from the Auth from a different
> > Table?
> >
> > [Auth] => Array
> >
> >         (
> >
> >             [User] => Array
> >
> >                 (
> >
> >                     [id] => 6
> >
> >                     [username] => mary
> >
> >                     [email] =>
> >
> >                     [group_id] => 4
> >
> >                     [created] => 2009-03-10 14:29:45
> >
> >                     [modified] => 2009-03-10 14:29:45
> >
> >                     [last_login] => 2009-03-10
> >
> >                 )
> >
> >         )
> >
> > For example here Mary is User ID 6 she belongs to Group 4 which in this
> case
> > is a TEACHER so she has a TEACHER profile which has an ID of 3. How can I
> > take the Auth id 6 to find her Teacher ID in the TEACHER TABLE?
> > Thanks
> > Dave
> >
>

--~--~---------~--~----~------------~-------~--~----~
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