Ok, i've found how to initialize parameters for the controller. It was
not difficult, actually, it's in the book. I paste my code here:
lass AppController extends Controller {
var $components = array(
'Auth' => array(
'authorize' => 'controller'
)
);
function beforeFilter(){
$this->Auth->allow('*');
}
function isAuthorized(){
return false;
}
}
The problem now is that i have to create a beforeFilter method in any
controller, even it's blank. I mean, if there's no beforeFilter in my
controller, Auth does not call to isAuthorized.
So, my custom controllers should all implement beforeFilter. It's a
litte frustrating. With this code, Auth doesn't check isAuthorized:
class CarsController extends AppController {
var $name = 'Cars';
function isAuthorized(){
debug(' Nobody will call me');
return false;
}
}
Do you know why is it?
On Jan 17, 6:39 pm, Santiago Basulto <[email protected]>
wrote:
> Hello people!
>
> I'm facing a problem with Auth component. I've a minor level of
> security in my site, that is checked in the isAuthorized() method of
> my AppController. I've there a simple switch that checks some options.
>
> The thing is that i need to declare a beforeFilter() in every
> controller and set inside that method the following statement
> "$this->Auth->authorize = 'controller'" to get Auth to call
> isAuthorized.
>
> I was wondering if there's some way of made that call "application
> wide". I mean, anyway to initialize the Auth component, where to do
> it, to make that (authorize = controller) the default. I tryied to do
> that in the method beforeFilter() of my AppController class, but it's
> not working.
>
> Altought i've found a way, that is to make this call on AppController
> beforeFilter() method:
> $this->Auth->isAuthorized('controller',$this);
>
> It works, but don't think it's a good way to do this. I've seen in the
> AuthComponent that there are some interesting methods that should be
> useful: initialize() and startup()
>
> Does anyone where to call them?
>
> Thanks everybody!
>
> --
> Santiago Basulto.-
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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