Skip to content

Commit e104e5d

Browse files
authored
Merge pull request #92 from flohdez/9.next-cake4
Add the ability to use a callback in bypassAuth in permissions
2 parents 00d896e + 0aa5317 commit e104e5d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Rbac/Rbac.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ protected function _matchPermission(array $permission, $user, $role, ServerReque
168168
'action' => $params['action'] ?? null,
169169
'role' => $role,
170170
];
171-
if (!$user && ($permission['bypassAuth'] ?? false) !== true) {
171+
$bypass = $permission['bypassAuth'] ?? false;
172+
if (is_callable($bypass)) {
173+
$bypass = $bypass($user, $role, $request);
174+
}
175+
if (!$user && $bypass !== true) {
172176
return null;
173177
}
174178
foreach ($permission as $key => $value) {

0 commit comments

Comments
 (0)