Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting which pages can be accessed in CakePHP
    primarykey
    data
    text
    <p>I've put a considerable amount of digging into this but I haven't been able to figure out what the best method would be.</p> <p>I have an employee management system where everyone who logs in is either an "employee", a "supervisor" or a "manager".</p> <p>At the moment, I display different versions of pages just fine depending on what their rank is. However, regular "employees" can still get to pages they shouldn't if they manually enter the URL. According to CakePHP's documentation, it says all pages are restricted by default, and you have to grant access to each one. But I haven't granted access and it seems all the pages are accessible.</p> <p>What is the best method for page access? Thanks!</p> <p>Edit: Here is the configuration of the AppController:</p> <pre><code> public $components = array( 'DebugKit.Toolbar', 'Session', 'Auth' =&gt; array( 'authenticate' =&gt; array( 'Form' =&gt; array( 'userModel' =&gt; 'Employee' ) ), 'loginAction' =&gt; array( 'controller' =&gt; 'employees', 'action' =&gt; 'login', //'plugin' =&gt; 'users' ), 'loginRedirect' =&gt; array('controller' =&gt; 'employees', 'action' =&gt; 'dashboard'), 'logoutRedirect' =&gt; array('controller' =&gt; 'employees', 'action' =&gt; 'login'), 'authError' =&gt; 'You must be logged in to see that.' ) ); </code></pre> <p>And then there is the isAuthorized() method which always is set to return false:</p> <pre><code>public function isAuthorized($user = null) { // Any registered user can access public functions /*if (empty($this-&gt;request-&gt;params['admin'])) { return true; }*/ // Only admins can access admin functions /*if (isset($this-&gt;request-&gt;params['admin'])) { return (bool)($user['role'] === 'admin'); }*/ // Default deny return false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload