Actually, here is my controller code incase it helps :)

Chris.

        public function beforeFilter(){
                $this->checkAccess();
        }

        protected final function checkAccess() {

                // if the session is no longer valid, refresh it
                if (!$this->Session->valid()) {
                        $this->Session->renew();
                }

                // if not logged in make the user anonymous
                if (!$this->Session->check(SESSION_KEY_USERNAME)) {
                        $this->Session->write(SESSION_KEY_USERNAME, 
'anonymous');
                }

                // get the user key from the session
                $user = $this->Session->read(SESSION_KEY_USERNAME);

                // get the aco from the url
                $aco = $this->params['controller'];

                if ($this->Acl->check($user, "/$aco", '*')) {
                        // if the user has access
                        return;
                } else {
                        if( $user == 'anonymous'){
                                // if the user is anonymous, go to login
                                $this->redirect("/users/login");
                        } else {
                                // if the user is denied access
                                $this->redirect("/pages/permission_denied");
                        }
                }
        }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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