Skip to content

Commit 46bee23

Browse files
authored
Update Guard.php
1 parent 63fbfec commit 46bee23

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Guard.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function enforce(string $permission, ActorInterface|RoleInterface $actor,
3030
case RuleMode::with:
3131
return $role->has($permission) && $rule->can($actor, $context);
3232
case RuleMode::without:
33-
return !$role->has($permission) && $rule->can($actor, $context);
33+
return $this->checkWithout($permission, $role, $rule, $actor, $context);
3434
case RuleMode::ever:
3535
return $rule->can($actor, $context);
3636
}
@@ -68,4 +68,16 @@ private function addRule(string $permission, RuleInterface $rule): void
6868
{
6969
$this->rules[$permission] = $rule;
7070
}
71+
72+
private function checkWithout(
73+
string $prmsn,
74+
RoleInterface $role,
75+
RuleInterface $rule,
76+
ActorInterface|RoleInterface $actor,
77+
object $context = null
78+
): bool
79+
{
80+
if ($role->has($prmsn)) return true;
81+
return $rule->can($actor, $context);
82+
}
7183
}

0 commit comments

Comments
 (0)