Skip to content

Commit

Permalink
Issue Fix directus#863
Browse files Browse the repository at this point in the history
  • Loading branch information
binal-7span committed Apr 29, 2019
1 parent 20e5fb6 commit 14f45af
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/core/Directus/Permissions/Acl.php
Expand Up @@ -1240,16 +1240,32 @@ public function enforceWriteField($collection, $fields, $status = null)
*
* @return boolean
*/
public function allowTo($action, $level, $collection, $status = null)
public function allowTo($action, $level, $collection, $status = null)
{
if ($this->isAdmin()) {
return true;
}

$permission = $this->getPermission($collection, $status);
$permissionLevel = ArrayUtils::get($permission, $action);

return $this->can($permissionLevel, $level);
if (count($permission) === 0) {
$statuses = $this->getCollectionStatuses($collection);

$allowed = false;
foreach ($statuses as $status) {
$permission = $this->getPermission($collection, $status);
$permissionLevel = ArrayUtils::get($permission, $action);
if ($this->can($permissionLevel, $level)) {
$allowed = true;
break;
}
}

return $allowed;
} else {
$permissionLevel = ArrayUtils::get($permission, $action);
return $this->can($permissionLevel, $level);
}
}

public function allowToOnce($action, $collection)
Expand Down

0 comments on commit 14f45af

Please sign in to comment.