fix: re-add missing voter code
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\Upload;
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
@@ -14,6 +15,7 @@ class DispositionVoter extends Voter
|
||||
public const EDIT = 'EDIT';
|
||||
public const DELETE = 'DELETE';
|
||||
public const CONTRACT = 'CONTRACT';
|
||||
public const CONTRACT_SUPPLEMENTARY = 'CONTRACT_SUPPLEMENTARY';
|
||||
public const INVOICE = 'INVOICE';
|
||||
public const FEEDBACK = 'FEEDBACK';
|
||||
|
||||
@@ -32,6 +34,7 @@ class DispositionVoter extends Voter
|
||||
static::EDIT,
|
||||
static::DELETE,
|
||||
static::CONTRACT,
|
||||
static::CONTRACT_SUPPLEMENTARY,
|
||||
static::INVOICE,
|
||||
static::FEEDBACK,
|
||||
]);
|
||||
@@ -49,6 +52,7 @@ class DispositionVoter extends Voter
|
||||
static::DELETE => $this->security->isGranted('ROLE_ADMIN'),
|
||||
static::FEEDBACK => $this->security->isGranted('ROLE_ADMINISTRATIVE')
|
||||
|| $this->assertHouseManagerAccess($token, $disposition),
|
||||
static::CONTRACT_SUPPLEMENTARY => $this->assertContractUploadAllowed($disposition),
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
@@ -84,4 +88,14 @@ class DispositionVoter extends Voter
|
||||
|
||||
return $user->getTeamer() === $disposition->getTeamer();
|
||||
}
|
||||
|
||||
private function assertContractUploadAllowed(Disposition $disposition): bool
|
||||
{
|
||||
if (false === $this->security->isGranted('ROLE_ADMINISTRATIVE')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Disposition::STATUS_ENDED === $disposition->getStatus()
|
||||
&& null === $disposition->getDocumentByType(Upload::TYPE_CONTRACT);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user