Ensure that the a lot / storage location owner is not the anonymous user

This commit is contained in:
Jan Böhmer 2023-04-08 00:50:42 +02:00
parent d32e902d17
commit bcda71cb25
3 changed files with 14 additions and 0 deletions

View file

@ -343,6 +343,13 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
*/
public function validate(ExecutionContextInterface $context, $payload)
{
//Ensure that the owner is not the anonymous user
if ($this->getOwner() && $this->getOwner()->isAnonymousUser()) {
$context->buildViolation('validator.part_lot.owner_must_not_be_anonymous')
->atPath('owner')
->addViolation();
}
//When the storage location sets the owner must match, the part lot owner must match the storage location owner
if ($this->getStorageLocation() && $this->getStorageLocation()->isPartOwnerMustMatch()
&& $this->getStorageLocation()->getOwner() && $this->getOwner()) {