Hi All

I'm still trying to put together a login system of admin and normal
users. It's pretty much working OK; but for some reason I can't fathom
when a user logs in they don;t get refdirected to the page specified
in Auth->loginRedirect(). Instead they end up back at the app root
page. I don't know if this is a problem with routes or something else
I've screwed up. Hope fully someone can help me. Here's some code:

In my app_controller I've this beforeFilter:

    function beforeFilter() {

        $this->Auth->loginRedirect = array('controller' =>
'dashboards', 'action' => 'showdashboard');

        //
        // Allow the user to see the home page and other static pages
        // without needing to log in.
        //
        $this->Auth->allow('display');
    }

This should send all users to their dashboard when they login. This
used to work before I implemented dual (admin and user) logins.

In my users_controller I've got admin and normal user login actions:

    function admin_login()
    {
        if($this->Auth->user())
        {
            $this->redirect(array('controller'=>'users',
'action'=>'index', 'admin' => true));
        }
    }

    function login()
    {
        if($this->Auth->user())
        {
            $this->redirect(array('controller'=>'dashboards',
'action'=>'showdashboard', 'admin' => false));
        }

    }
The redirect in the normal users login action was supposed to do the
same thing as the loginRedirect in the app_controller beforeFilter.

Finally I've a home.ctp in /views/pages/:
<ul>
<li><?php echo $html->link(__('User Login', true), array('controller'
=> 'users', 'action'=>'login', 'admin' => false));?></li>
<li><?php echo $html->link(__('Administrator Login', true), array
('controller' => 'users', 'action'=>'login', 'admin' => true));?></li>
</ul>

If I click on either of these links I get the correct login form and I
can log in; but instead of going to either /dashboards/showdashboard/
or to /users/index/ (depending on whether it's an admin login or a
normal user login) I end up back at home.ctp and then have to navigate
from there.

Why are these redirects not working for me?

Thanks

David

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