Applied API role specs to domains list

This commit is contained in:
Alejandro Celaya
2021-01-04 15:55:59 +01:00
parent 262a06f624
commit 19834f6715
9 changed files with 40 additions and 16 deletions

View File

@@ -76,6 +76,11 @@ class ApiKey extends AbstractEntity
public function isAdmin(): bool
{
return $this->roles->count() === 0;
return $this->roles->isEmpty();
}
public function hasRole(string $roleName): bool
{
return $this->roles->exists(fn ($key, ApiKeyRole $role) => $role->name() === $roleName);
}
}