mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 04:30:08 +02:00
Restrict part lot withdraw/add/move operations to the owner of a part lot
This commit is contained in:
parent
447b54fa4b
commit
a7ff690891
3 changed files with 59 additions and 18 deletions
|
@ -67,7 +67,15 @@ class PartLotVoter extends ExtendedVoter
|
|||
|
||||
if (in_array($attribute, ['withdraw', 'add', 'move']))
|
||||
{
|
||||
return $this->resolver->inherit($user, 'parts_stock', $attribute) ?? false;
|
||||
$base_permission = $this->resolver->inherit($user, 'parts_stock', $attribute) ?? false;
|
||||
|
||||
$lot_permission = true;
|
||||
//If the lot has an owner, we need to check if the user is the owner of the lot to be allowed to withdraw it.
|
||||
if ($subject instanceof PartLot && $subject->getOwner()) {
|
||||
$lot_permission = $subject->getOwner() === $user || $subject->getOwner()->getID() === $user->getID();
|
||||
}
|
||||
|
||||
return $base_permission && $lot_permission;
|
||||
}
|
||||
|
||||
switch ($attribute) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue