title: Roles in CakePHP Auth Component
body: <p>I'm trying to use roles in the CakePHP Auth component. The roles would be user, admin, super-admin, etc. I'm having difficulty with placing a conditional in each controller based off the user role. I tried the following and it didn't work:</p>
  
  <pre><code>function  beforeFilter() {
          parent::beforeFilter();
          $this-&gt;Auth-&gt;allow('add');
  
          if($this-&gt;Auth-&gt;user('roles') == 'admin') {
              $this-&gt;Auth-&gt;allow('index', 'add', 'edit', 'delete');
          } 
          elseif($this-&gt;Auth-&gt;user('roles') == 'super-admin') {
              $this-&gt;Auth-&gt;allow('index', 'add', 'edit', 'delete', 'make_super_admin', 'privileges'); //Note difference in superadmin priviledges
  
          }
  </code></pre>
  
  <p>The problem is with the conditional. I want the function to go in each controller (UsersController, PatientsController, AdmissionsController, etc.) and based off the user role, give different permissions.</p>