Skip to content

Instantly share code, notes, and snippets.

@ahebrank
Created April 25, 2024 00:32
Show Gist options
  • Save ahebrank/f45febf3767bdc68fda1b453afe2e1ca to your computer and use it in GitHub Desktop.
Save ahebrank/f45febf3767bdc68fda1b453afe2e1ca to your computer and use it in GitHub Desktop.
diff --git a/vapn.module b/vapn.module
index ffcc861..35bb5ce 100644
--- a/vapn.module
+++ b/vapn.module
@@ -70,6 +70,12 @@ function vapn_node_access(NodeInterface $entity, $operation, AccountInterface $a
$rid = $item->target_id;
$allowed_roles[$rid] = $rid;
}
+
+ // Nothing marked on a node? Allow by default.
+ if (empty($allowed_roles)) {
+ return AccessResult::neutral();
+ }
+
$access_result = array_intersect($account->getRoles(), $allowed_roles)
? AccessResult::allowed()
: AccessResult::forbidden();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment