mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Ensure that the a lot / storage location owner is not the anonymous user
This commit is contained in:
parent
d32e902d17
commit
bcda71cb25
3 changed files with 14 additions and 0 deletions
|
@ -343,6 +343,13 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
||||||
*/
|
*/
|
||||||
public function validate(ExecutionContextInterface $context, $payload)
|
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
|
//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()
|
if ($this->getStorageLocation() && $this->getStorageLocation()->isPartOwnerMustMatch()
|
||||||
&& $this->getStorageLocation()->getOwner() && $this->getOwner()) {
|
&& $this->getStorageLocation()->getOwner() && $this->getOwner()) {
|
||||||
|
|
|
@ -94,6 +94,7 @@ class Storelocation extends AbstractPartsContainingDBElement
|
||||||
* @var User|null The owner of this storage location
|
* @var User|null The owner of this storage location
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User")
|
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User")
|
||||||
* @ORM\JoinColumn(name="id_owner", referencedColumnName="id", nullable=true, onDelete="SET NULL")
|
* @ORM\JoinColumn(name="id_owner", referencedColumnName="id", nullable=true, onDelete="SET NULL")
|
||||||
|
* @Assert\Expression("this.getOwner() == null or this.getOwner().isAnonymousUser() === false", message="validator.part_lot.owner_must_not_be_anonymous")
|
||||||
*/
|
*/
|
||||||
protected ?User $owner = null;
|
protected ?User $owner = null;
|
||||||
|
|
||||||
|
|
|
@ -311,5 +311,11 @@
|
||||||
<target>The owner of this lot must match the owner of the selected storage location (%owner_name%)!</target>
|
<target>The owner of this lot must match the owner of the selected storage location (%owner_name%)!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit id="HXSz3nQ" name="validator.part_lot.owner_must_not_be_anonymous">
|
||||||
|
<segment>
|
||||||
|
<source>validator.part_lot.owner_must_not_be_anonymous</source>
|
||||||
|
<target>A lot owner must not be the anonymous user!</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue