user1152226
user1152226

Reputation: 323

CakePhp ACL check fails in app but not in the cake console

I am building an app that requires the use of an ACL. I am trying to check permissions in an action in one of my controllers. This is my cake console code, which works:

./cake acl check Group.83 controllers all
Group.83 is allowed.

However, in my controller when i use this code, which should return true:

$checkPerm = $this->Acl->check('Group.83', 'controllers', 'all');

I get this error:

Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check.  Node references:
Aro: Group.83
Aco: controllers [CORE/cake/libs/controller/components/acl.php, line 273]

I know that my ACL is setup up correctly, otherwise the cake console command would have failed. Its something in my controller i think, but I am not sure what could be causing this error. Any ideas?

Upvotes: 0

Views: 503

Answers (1)

jeremyharris
jeremyharris

Reputation: 7882

The shell uses the dot syntax because an array or forward slash wouldn't work. The shell then extracts and makes it readable by the component, which uses an array syntax. Change your check to:

$checkPerm = $this->Acl->check(array(
  'model' => 'Group',
  'foreign_key' => 83
), 'controllers', 'all');

And that should take care of it!

Upvotes: 1

Related Questions