Fixing incorrect selection of parent nodes in ACL, fixes #4324

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6653 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-04-11 04:59:52 +00:00
parent 017c07c7bf
commit c7677c2a5e
2 changed files with 12 additions and 0 deletions

View file

@ -128,6 +128,15 @@ class AclNode extends AppModel {
);
}
$result = $db->read($this, $queryData, -1);
$path = array_values($path);
if (
!isset($result[0][$type]) ||
(!empty($path) && $result[0][$type]['alias'] != $path[count($path) - 1]) ||
(empty($path) && $result[0][$type]['alias'] != $start)
) {
return false;
}
} elseif (is_object($ref) && is_a($ref, 'Model')) {
$ref = array('model' => $ref->alias, 'foreign_key' => $ref->id);
} elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {

View file

@ -174,6 +174,9 @@ class AclComponentTest extends CakeTestCase {
$this->assertFalse($this->Acl->check('Manager', 'Reports', 'create'));
$this->assertTrue($this->Acl->check('Secretary', 'Links', 'create'));
$this->expectError('DB_ACL::allow() - Invalid node');
$this->assertFalse($this->Acl->allow('Manager', 'Links/DoesNotExist', 'create'));
}
function testDbAclCheck() {