Ok. I solved the problem. Here are the steps and changes I made to my
code. I hope this can help someone to fix an similar problem.

1.) app_controller

$this->Auth->loginRedirect = '/users/loginRedirect';
$this->Auth->autoRedirect = false;

2.) users_controller

        function login()
        {
                if ($this->Auth->login())
                 {
                        $this->loginRedirect();
                 }
        }

        function logout()
        {
                $this->Session->setFlash('Sie sind abgemeldet.');
                $this->Auth->logout();
                $this->redirect($this->Auth->logoutRedirect);
                $this->Session->del('Auth.redirect');
                $this->Session->del('referer');
        }

        function loginRedirect()
        {
                $userinfo = $this->Auth->user();

        switch($userinfo['User']['group_id'])
                {
                        case '1': $this->redirect(array (
                                                'controller' => 'members', 
'action' => 'index'), null, true);
                                break;

                case '4': $this->redirect(array (
                                                'controller' => 'members', 
'action' => 'otherList'), null,
true);
                                break;

                default: $this->redirect(array (
                                                'controller' => 'members', 
'action' => 'index'), null, true);
        }
        }

Thanks for your help,
draikin


On 27 Mai, 22:04, brian <[email protected]> wrote:
> On Tue, May 26, 2009 at 3:57 PM, draikin <[email protected]> wrote:
>
> > This doesn't work for me. I added the redirekt in app_controller and
> > create a new function home() in users_controller:
>
> >        function home()
> >        {
> >                $userinfo = $this->Auth->user(); // assuming the group is in 
> > there
> >                switch($userinfo['User']['group_id'])
> >                {
> >                        case '1': $this->redirect(array (
> >                                                'controller' => 'members', 
> > 'action' => 'index'), null, true);
> >                                break;
>
> >                case '4': $this->redirect(array (
> >                                                'controller' => 'members', 
> > 'action' => 'otherList'), null,
> > true);
> >                                break;
>
> >                default: $this->redirect(array (
> >                                                'controller' => 'members', 
> > 'action' => 'index'), null, true);
> >        }
> >        }
>
> > If I firstloginas member of group '4', all the redirection is
> > correct.Afterlogout andloginas member of group '1' I get the same
> > redirection as before. Not the  expected redirection to /members/
> > index.
>
> > Whats going wrong here?
>
> Not sure. But you're still adding an extraredirectif you do it from home().
>
> I'm also not sure what happened to my other post. This is what I'm using:
>
> AppController::beforeFilter()
>
> $this->Auth->loginRedirect = array('controller' => 'pages', 'action'
> => 'display', 'home');
>
> UsersController::login()
>
> if ($this->Auth->user('group_id') > 3)
> {
>         ...
>         $this->redirect($this->Auth->loginRedirect);}
>
> ...
> $this->redirect(
>         array(
>                 'controller' => 'sections',
>                 'action' => 'index',
>                 'admin' => 1
>         )
> );
--~--~---------~--~----~------------~-------~--~----~
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