You could simple do this by  adding a admin boolean to the users table,
and test $data['User']['admin']

or if you want to do it with groups you can do a find on the logged user
like this:

$user = $this->User->find('all');

and here you will have the user data and it's groups

if you want to do this in login action then set in the beforeFitler():
        $this->Auth->autoRedirect = false;
or if you want to cancel the auth redirection only for login action do:
if ($this->params['action'] == 'login' || $this->params['action'] ==
'admin_login') {
        $this->Auth->autoRedirect = false;
}

dunno if this is what you want but you can access the join model like
this:
$this->User->GroupsUser
cake automatically creates it for you


On Wed, 2009-05-27 at 11:35 +0000, lakers fan wrote:
> Sorry let me refine my question.  I have a user model which has a list
> of groups. namely 'user', 'admin' etc.  Similarly the group has
> multiple users. I have an associate for this in my User model:
>  
>     var $hasAndBelongsToMany = array(  
>             'Group' => array('className' => 'Group',  
>                         'joinTable' => 'groups_users',  
>                         'foreignKey' => 'user_id',  
>                         'associationForeignKey' => 'group_id',  
>                         'unique' => true  
>             )  
>     ); 
>  
>  
> Now I have two logins,
> http://localhost/cake/admin/users/login for admin
> http://localhost/cake/users/login for regular users.
>  
> when a user logins in say as admin, I need to get the groupid
> associated in groups_users table so that I can redirect him to
> appropriate admin page. Same is true for regular users..
> Both admin and regular users use the same User model. Is there a way
> to differenciate between these two users?
>  
> Thanks,
> Bharani
>  
> 
>  
> > Subject: Re: Admin Login
> > From: [email protected]
> > To: [email protected]
> > Date: Wed, 27 May 2009 12:24:15 +0300
> > 
> > 
> > Take a look at this:
> > http://book.cakephp.org/view/172/Authentication
> > and this:
> > http://book.cakephp.org/view/46/Routes-Configuration at Prefix
> routing
> > 
> > On Wed, 2009-05-27 at 08:56 +0000, lakers fan wrote:
> > > Hello,
> > > I have a requirement, I have two logins .. one for normal users
> > > and one for administrators. I have two login pages separately. In
> my
> > > users' controller, I have login() and adminlogin() actions. For
> normal
> > > users I want to use users table to check the username and
> password,
> > > and for administrator, i want to use users table and groups table.
> > > groups table is the user groups such as admin and www. How can i
> do
> > > validation using Auth for both in users controller.
> > > 
> > > Thanks,
> > > Bharani
> > > 
> > > 
> > >
> ______________________________________________________________________
> > > HotmailĀ® has a new way to see what's up with your friends. Check
> it
> > > out.
> > > > 
> > 
> > 
> > > 


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