feat: integrate with htmx
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Entity\Assignment;
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
@@ -16,8 +17,11 @@ class AssignmentVoter extends Voter
|
||||
public const EDIT = 'EDIT';
|
||||
public const APPLY = 'APPLY';
|
||||
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{}
|
||||
public function __construct(
|
||||
private readonly Security $security,
|
||||
private readonly EntityManagerInterface $entityManager
|
||||
) {
|
||||
}
|
||||
|
||||
protected function supports(string $attribute, mixed $subject): bool
|
||||
{
|
||||
@@ -40,7 +44,7 @@ class AssignmentVoter extends Voter
|
||||
|
||||
// Only users with administrative role may edit assignments
|
||||
if (static::EDIT === $attribute) {
|
||||
return in_array('ROLE_ADMINISTRATIVE', $token->getRoleNames());
|
||||
return $this->security->isGranted('ROLE_ADMINISTRATIVE');
|
||||
}
|
||||
|
||||
// Only allow applications to open assignments
|
||||
@@ -61,7 +65,7 @@ class AssignmentVoter extends Voter
|
||||
}
|
||||
|
||||
// Only teamers without existing applications may apply to the assignment
|
||||
if (in_array('ROLE_TEAMER', $token->getRoleNames())) {
|
||||
if ($this->security->isGranted('ROLE_TEAMER')) {
|
||||
/** @var User $user */
|
||||
$user = $token->getUser();
|
||||
$teamer = $user->getTeamer();
|
||||
|
||||
Reference in New Issue
Block a user