Checking Access

In a controller, just add this to one of your actions (for example, actionBrowse()):

// in place of the word 'browse', you could use $this->_action
if (Solar_Registry::get('user')->access->isAllowed(get_class($this), 'browse')) {
    // browse logic
}
else {
    // access denied logic
}

Or, better yet, follow the _preAction() method in Solar_Base.

protected function _preAction()
{
    $allow = Solar_Registry::get('user')->access->isAllowed(
        get_class($this),
        $this->_action
    );
 
    if (! $allow) {
        $this->errors[] = $this->locale('ERR_NOT_ALLOWED_ACCESS');
        $this->_action = 'error';
    }
}
 
manual/access/access.txt · Last modified: 2009/07/11 22:28 by jelofson