Well quite normal since as long as you are not logged in beforeFilter
has no much effect on redirection ..
Better, use $this->Auth->autoRedirect = false; in beforeFilter ..

In login,

if($this->Auth->user('id'))
{
    if($this->Auth->user('admin') == 'n')
        blah;
    else
        otherblah ...
}

hth

On Nov 5, 4:03 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi all,
>
> I have a simple app that needs to have 2 types of users, normal users
> and admins. I have got the Auth component working great and has the
> entire site requiring log in etc, but I want to redirect users that
> are admins to the admin route sections upon login.
>
> I have this in my app_controller:
>
>     function beforeFilter() {
>         $this->Auth->allow('display');
>         $this->Auth->logoutRedirect =
> array(Configure::read('Routing.admin') => false, 'controller' =>
> 'users', 'action' => 'logout');
>         $user = $this->Auth->user();
>         //debug($user);
>         if($user['User']['admin'] == 'n') {
>             $this->Auth->loginRedirect = array('controller'=>'orders',
> 'action'=>'index');
>         } else {
>             $this->Auth->loginRedirect = array('controller'=>'orders',
> 'action'=>'index', 'admin' => true);
>         }
>
>     }
>
> And while it doesnt throw errors it seems to behave wierdly - it
> redirects to the /admin route regardless, but if I go back in my
> browser and login again it redirects to the correct page!
>
> Has anyone tried to do this before? Any suggestions what I may be
> missing?
> TIA,
> d.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to