mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-09 16:53:11 +08:00
Reduce duplicated logic when checking if an API key is admin
This commit is contained in:
@@ -114,9 +114,12 @@ class ApiKey extends AbstractEntity
|
||||
return Spec::andX(...$specs);
|
||||
}
|
||||
|
||||
public function isAdmin(): bool
|
||||
/**
|
||||
* @return ($apiKey is null ? true : boolean)
|
||||
*/
|
||||
public static function isAdmin(?ApiKey $apiKey): bool
|
||||
{
|
||||
return $this->roles->isEmpty();
|
||||
return $apiKey === null || $apiKey->roles->isEmpty();
|
||||
}
|
||||
|
||||
public function hasRole(Role $role): bool
|
||||
|
||||
Reference in New Issue
Block a user