Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP Acl confusion - denied access to group but user of that group has access
    primarykey
    data
    text
    <p>Now I must be missing something in my ACL-controlled application. My User model belongsTo a model called Role. I have included the ACL behaviour in both models. Both models have parentNode functions - in Role, this returns null. In User, the code is below:</p> <pre><code>public function parentNode() { if (!$this-&gt;id &amp;&amp; empty($this-&gt;data)){ return null; } if (isset($this-&gt;data['User']['role_id'])){ $roleId = $this-&gt;data['User']['role_id']; } else { $roleId = $this-&gt;field('role_id'); } if (!$roleId){ return null; } else { return array('Role' =&gt; array('id' =&gt; $roleId)); } } </code></pre> <p>I'm logged in as a user that has role_id = 8. In my aros table, the user has a parent_id of 9, which is the aro entry for the correct role.</p> <p>I created the following action to illustrate the problem:</p> <pre><code>public function permissions(){ $this-&gt;autoRender = false; if($this-&gt;Acl-&gt;check(array('model'=&gt;'User','foreign_key'=&gt;$this-&gt;Auth-&gt;user('id')),'Countries')){ echo 'User: Allowed&lt;br /&gt;'; }else{ echo 'User: Forbidden&lt;br /&gt;'; } if ($this-&gt;Acl-&gt;check(array('model'=&gt;'Role','foreign_key'=&gt;$this-&gt;Auth-&gt;user('role_id')),'Countries')){ echo 'Role: Allowed'; }else{ echo 'Role: Forbidden'; } } </code></pre> <p>When I run the action, I get:</p> <pre><code>User: Allowed Role: Forbidden </code></pre> <p>The user entry does not have any entries in the aros_acos table. The only entries in that table are for Role aros.</p> <p>Can anyone shed any light on this?</p> <p>Thanks.</p> <p>Edit - just in case it's not clear, the expected behaviour would be that both the user and the role are forbidden from accessing this controller ('Countries').</p> <p>Edit - I do assign permissions, like so:</p> <pre><code> $this-&gt;Acl-&gt;deny('City admin','Countries'); </code></pre> <p>I've verified in the database that this has worked.</p>
    singulars
    1. This table or related slice is empty.
    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