feat: integrate with htmx
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Security\Voter;
|
||||
|
||||
use App\Entity\Upload;
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
@@ -14,6 +15,10 @@ class UploadVoter extends Voter
|
||||
public const DOWNLOAD = 'DOWNLOAD';
|
||||
public const CHECK = 'CHECK';
|
||||
|
||||
public function __construct(private readonly Security $security)
|
||||
{
|
||||
}
|
||||
|
||||
protected function supports(string $attribute, mixed $subject): bool
|
||||
{
|
||||
if (! $subject instanceof Upload) {
|
||||
@@ -29,7 +34,7 @@ class UploadVoter extends Voter
|
||||
$upload = $subject;
|
||||
|
||||
// Administrative users have full access
|
||||
if (true === in_array('ROLE_ADMINISTRATIVE', $token->getRoleNames())) {
|
||||
if (true === $this->security->isGranted('ROLE_ADMINISTRATIVE')) {
|
||||
// Only new documents may be checked
|
||||
if (static::CHECK === $attribute) {
|
||||
return in_array($upload->getStatus(), [Upload::STATUS_NEW, Upload::STATUS_PENDING]);
|
||||
|
||||
Reference in New Issue
Block a user