mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-02 06:24:34 +02:00
Added permissions to label system.
This commit is contained in:
parent
fde1d7be4f
commit
5a9be023b1
6 changed files with 62 additions and 27 deletions
|
@ -27,12 +27,19 @@ use App\Entity\UserSystem\User;
|
|||
class LabelProfileVoter extends ExtendedVoter
|
||||
{
|
||||
|
||||
protected const MAPPING = [
|
||||
'read' => 'read_profiles',
|
||||
'create' => 'create_profiles',
|
||||
'edit' => 'edit_profiles',
|
||||
'delete' => 'delete_profiles',
|
||||
];
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
return true;
|
||||
return $this->resolver->inherit($user, 'labels', self::MAPPING[$attribute]) ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +48,11 @@ class LabelProfileVoter extends ExtendedVoter
|
|||
protected function supports($attribute, $subject)
|
||||
{
|
||||
if ($subject instanceof LabelProfile) {
|
||||
return true;
|
||||
if (!isset(self::MAPPING[$attribute])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->resolver->isValidOperation('labels', self::MAPPING[$attribute]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue