I do something like this:
function isAuthorized() {
if (strpos($this->action,"admin") !== false){
return $this->isAdmin();
}
if (strpos($this->action,"clerk") !== false){
return $this->isClerkOrAdmin();
}
return true;
}
My isAdmin() and isClerkOrAdmin() functions look at various things
(Session, DB, etc..) to decide if the user can view such an action.
Hope that helps,
Nick
On Sep 15, 7:22 pm, "Dave Maharaj" <[email protected]> wrote:
> How do you write a good isAuthorized function?
>
> My old one pre 1.3 simply read the routing for the specific group
>
> $manage = Configure::read( 'Routing.manage' );
>
> if ( isset( $this->params[$manage]) && $this->params[$manage] ) {
> if ( $this->Session->valid() == true && $this->Auth->User(
> 'role_id' ) == '456456456456456456456456' ) {
> $this->layout = 'manager';
> $access = true;
> } else {
> $this->Session->destroy();
> $this->Session->setFlash(__( 'You have been logged
> out.', true ), 'default', array() );
>
> }
> }
>
> But now $routes = Configure::read('Routing.prefixes');
>
> So I get
>
> Array
> (
> [0] => admin
> [1] => manager
> [2] => editor
> [3] => contributor
> )
>
> My roles table does not call them the same thing such as role is
> Administrator but routed using admin.
>
> Helpful insights anyone?
>
> Thanks
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