Hi,

i believe because you have the authorize variable set to controller, you need 
to include an isAuthorized method in each of your controllers. Try putting the 
following (and removing the beforeFilter) in your Posts controller:

function isAuthorized() {
       return parent::isAuthorized('someuser');
}
 
This inherits and returns the value from isAuthorized in the AppController, you 
could change $user to pass in directly the role too. I hope that's 
correct/works as I'm about to implement pretty much the same feature in a web 
site too! :)

Clint


> Hi,
> 
> I asked this just some days ago, but I am still stuck with this:
> 
> I have a web project where I want to give the admin a "admin area"
> where he can login and add/edit/delete news.
> The basic code for this I took from the cake book given with the blog
> tutorial.
> 
> I having now a problem with the AUTH part:
> 
> AppController:
> public $components = array(
>    'Session',
>    'Auth' => array(
>        'loginRedirect' => array('controller' => 'posts', 'action' =>
> 'index'),
>        'logoutRedirect' => array('controller' => 'pages', 'action' =>
> 'display', 'home'),
>        'authorize' => array('Controller'),
>        'authError' => 'Bitte loggen Sie sich ein!'
>    )
> );
> function beforeFilter() {
>        $this->Auth->allow('display');
>    }
> public function isAuthorized($user) {
>        if (isset($user['role']) && $user['role'] === 'admin') {
>            return true; //Admin can access every action
>        }
>        return false; // The rest don't
>    }
> 
> The User I added, has the role 'admin'
> 
> I want all function from the posts controller to be secured by Auth.
> 
> My major understanding problem is inside the posts controller with
> this function:
> 
> public function beforeFilter() {
>        parent::beforeFilter();
>        $this->Auth->allow('?');
>    }
> 
> I don't want to allow any function.
> But when I remove the function beforeFilter I can't login. I don't get
> any error messages, I just see the again and again the login form
> coming up. Even the same when I just remove the $this->Auth->allow
> line.
> 
> What is wrong here?
> I really don't get it....
> 
> Please help me!!
> 
> 
> 
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to