Master ALWAYS has ANY role

This commit is contained in:
2023-06-06 14:43:02 +01:00
parent e86ab03f06
commit 575b5d5b36

View File

@@ -53,6 +53,11 @@ class HasRoleExtension extends AbstractExtension implements GlobalsInterface
// Add Twig function for checking permissions during dynamic menu rendering
new TwigFunction('hasRole', function ($roleSlug) {
$currentUser = $this->services->currentUser;
if ($currentUser->isMaster()) {
return true;
}
return $currentUser->roles()->where('slug', $roleSlug)->count() > 0;
}),
];