mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 04:30:08 +02:00
Added permission to control if a user is allowed to withdraw/add/move parts
This commit is contained in:
parent
89a4846259
commit
60d5776cb7
7 changed files with 55 additions and 5 deletions
|
@ -57,7 +57,7 @@ class PartLotVoter extends ExtendedVoter
|
|||
$this->security = $security;
|
||||
}
|
||||
|
||||
protected const ALLOWED_PERMS = ['read', 'edit', 'create', 'delete', 'show_history', 'revert_element'];
|
||||
protected const ALLOWED_PERMS = ['read', 'edit', 'create', 'delete', 'show_history', 'revert_element', 'withdraw', 'add', 'move'];
|
||||
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
|
@ -65,6 +65,11 @@ class PartLotVoter extends ExtendedVoter
|
|||
throw new \RuntimeException('This voter can only handle PartLot objects!');
|
||||
}
|
||||
|
||||
if (in_array($attribute, ['withdraw', 'add', 'move']))
|
||||
{
|
||||
return $this->resolver->inherit($user, 'parts_stock', $attribute) ?? false;
|
||||
}
|
||||
|
||||
switch ($attribute) {
|
||||
case 'read':
|
||||
$operation = 'read';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue