Skip to content

Commit

Permalink
search updated
Browse files Browse the repository at this point in the history
  • Loading branch information
s3b4stian committed Nov 27, 2023
1 parent 285bf6a commit 0301f1f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Linna/Authorization/PermissionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public function canById(null|int|string $permissionId): bool
return true;
}

if (\in_array($permissionId, \array_column($this->permission, 'id'), true)) {
return true;
}

return false;
}

Expand All @@ -62,6 +66,10 @@ public function canById(null|int|string $permissionId): bool
*/
public function canByName(string $permissionName): bool
{
if (isset($this->permission[$permissionName])) {
return true;
}

if (\in_array($permissionName, \array_column($this->permission, 'name'), true)) {
return true;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Linna/Authorization/RoleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function hasRoleById(null|int|string $roleId): bool
return true;
}

if (\in_array($roleId, \array_column($this->role, 'id'), true)) {
return true;
}

return false;
}

Expand All @@ -59,6 +63,10 @@ public function hasRoleById(null|int|string $roleId): bool
*/
public function hasRoleByName(string $roleName): bool
{
if (isset($this->role[$roleName])) {
return true;
}

if (\in_array($roleName, \array_column($this->role, 'name'), true)) {
return true;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Linna/Authorization/UserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function hasUserById(null|int|string $userId): bool
return true;
}

if (\in_array($userId, \array_column($this->user, 'id'), true)) {
return true;
}

return false;
}

Expand All @@ -59,6 +63,10 @@ public function hasUserById(null|int|string $userId): bool
*/
public function hasUserByName(string $userName): bool
{
if (isset($this->user[$userName])) {
return true;
}

if (\in_array($userName, \array_column($this->user, 'name'), true)) {
return true;
}
Expand Down

0 comments on commit 0301f1f

Please sign in to comment.