Hi everybody,

I use the AuthComponent on my site for authentication. I've specified
all of the things that it needs to know in the app_controller.php,
where I also set a variable, $user, which contains the object of the
current user. I use this for showing custom menus, log out links etc.

However, I'm also using the built-in PagesController to show static
pages on the site. But apparently the $user variable isn't set when
viewing pages. I tried adding the AuthComponent directly to the
PagesController, allowing all pages, and setting the $user variable
directly in the PagesController also. Still, menus and links don't
show up.

Any suggestions here? This is the code for app_controller.php,

<?php
class AppController extends Controller
{
        var $helpers = array( 'Html', 'Javascript', 'Form' );
        var $components = array( 'Auth' );

        function beforeFilter()
        {
                Security::setHash('sha1');

                $this->Auth->loginAction = '/users/login';
                $this->Auth->loginRedirect = array('controller' => 'events',
'action' => 'index');
                $this->Auth->logoutRedirect = '/events/index';
                $this->Auth->loginError = __('Wrong username or password.', 
true);
                $this->Auth->authError = __('You have to log in to access this
page.', true);
                $this->Auth->authorize = 'controller';
                $this->Auth->deny('*');

                if ($this->Auth->user())
                {
                        $this->set('user', $this->Auth->user());
                }
                else
                {
                        $this->set('user', null);
                }
        }

        public function isAuthorized()
        {
                return true;
        }
}
?>

Thanks in advance :)

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