/**
* Groups as id => array(name => <string>, roles => <array>)
*/
'groups' => array(
-1 => array('name' => 'Banned', 'roles' => array('banned')),
0 => array('name' => 'Guests', 'roles' => array('guest')),
1 => array('name' => 'Users', 'roles' => array('user')),
1000 => array('name' => 'Super Administrators', 'roles' => array('super')),
),
/**
* Roles as name => array(location => rights)
*/
'roles' => array(
'#' => array('users' => array('signup', 'login')), // default rights
'user' => array('comments' => array('create', 'read')),
'moderator' => array('comments' => array('update', 'delete')),
'admin' => array(
'website' => array('create', 'update', 'delete'),
'admin' => array('create', 'read', 'update', 'delete'),
),
'banned' => false,
'super' => true,
),
...
In your example, how would controllers that don't use any models?$access = Auth::has_access(array(
"model_name",
"create"
));
Jelmer Schreuder wrote on Sunday 2nd of October 2011:My controller methods are loaded through a Controller router() method that catches Exceptions, in this case AccessDeniedException that is thrown by the Model when a user with insufficient rights tries to access a model he doesn't have access to. When such an exception is caught an error view is returned. Most of these operations are "create", "update", "read", "delete" but all go through a central access point to the model that does the rights checking based on the model name and the method requested.
public function router($method, $args)
{
try
{
return call_user_func_array(array($this, $method), $args);
}
catch (AccessDeniedException $e)
{
return ViewModel::forge('access_denied', array('error' => $e));
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!