I searched around trying to find similar problems but I didn't run
into any. If I missed a relevant discussion, pointing me in their
direction would be much obliged.

The first two problems are both with AuthComponent::Allow(). Here's a
snippet from my Users Controller:

function beforeFilter() {
        $this->Auth->allow('login', 'register', 'recover');
        $this->set('auth_status', $this->Auth->isAuthorized());
}

The first line is to allow access to certain actions of the users
controller that any user (logged in or not) can access. The second
line sets a variable in my view that is used to determine the contents
of the horizontal menu bar of the default layout (so that I can show
the links "Control Panel" and "Logout" instead of "Login" and
"Register").

The first problem is with the first line. As long as that line is in
the beforeFilter() method, logging in will always be unsucessful,
irrespective of what the user inputs. The solution was to move it to
the beforeFilter() method of the AppController class, which worked.
However, I would prefer to have it set in the UsersController class to
ease maintenance. If anybody has a solution, please share. Here's my
AppController class:

<?php
class Appcontroller extends Controller {
        var $components = array('Acl', 'Auth');

        var $allowed = array('pages' => '*', '');

        function beforeFilter() {
                if(isset($this->Auth)) {
                        $this->Auth->loginAction = '/users/login';
                        $this->Auth->loginRedirect = '/users/manage';
                        $this->Auth->logoutRedirect = '/';

                        $this->Auth->allow($this->allowed);
                }

                $this->Auth->allow('login', 'register', 'recover');
        }
}
?>

The second problem comes from the second line of the UsersController's
beforeFilter() method. I wanted to have that line in the
AppController's beforeFilter() method, so it would work for any
controller and any action, but it only works for the root page and
nothing more. Thus, I have to include the same line in all my
controllers. This probably only has to do with my understanding of how
Cake PHP implements the MVC pattern, but an explanation would be
appreciated.

My third and final problem is allowing the home page to those who are
not logged in. I've figured how to grant access to any controller or
any individual action EXCEPT the home page. Again, help appreciated.

Thanks,
-Nick


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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