josegonzalez/sanction — Issue #15: Readme Help Doc Updates - More permission examples
Author: sugitime
Created: 2011-12-19 18:06:57+00:00
State: open

Allowing anonymous access:

Permit::access(
array('controller' => array('posts'), 'action' => array('index')),
array(),
array()
);

Allowing access to multiple roles:
Permit::access(
array('controller' => array('posts'), 'action' => array('add', 'delete')),
array('auth' => array('User.role' => array('user', 'admin'))),
array('redirect' => array('controller' => 'posts', 'action' => 'index'),
'message' => 'You are not authorized to perform the requested action.'
)
);

This is helpful because if the Admin's permissions are declared to allow access to ALL actions in 'posts', then the example above is added to permits.php, if admin is not included in this declaration, they are not given the access rights to 'add' or 'delete'.