diff --git a/src/Security/Voter/ApplicationVoter.php b/src/Security/Voter/ApplicationVoter.php index 204bcaa..1a3ad0d 100644 --- a/src/Security/Voter/ApplicationVoter.php +++ b/src/Security/Voter/ApplicationVoter.php @@ -31,18 +31,23 @@ class ApplicationVoter extends Voter /** @var Application $application */ $application = $subject; + if ($user->hasRole('ROLE_TEAMER')) { + return match ($attribute) { + static::DELETE => $user->getTeamer() === $application->getTeamer() && Application::STATUS_REJECTED === $application->getStatus(), + static::VIEW => $user->getTeamer() === $application->getTeamer() && Application::STATUS_REJECTED !== $application->getStatus(), + default => false, + }; + } + if ($user->hasRole('ROLE_ADMINISTRATIVE')) { return match ($attribute) { - static::VIEW, static::DELETE => true, + static::VIEW => true, + static::DELETE => Application::STATUS_REJECTED === $application->getStatus(), static::DISPOSE, static::REJECT => Application::STATUS_REJECTED !== $application->getStatus(), default => false, }; } - if (static::VIEW === $attribute && $user->hasRole('ROLE_TEAMER')) { - return $user->getTeamer() === $application->getTeamer(); - } - return false; } } \ No newline at end of file diff --git a/templates/teamer/application/index.html.twig b/templates/teamer/application/index.html.twig index 06ecd76..83a8065 100644 --- a/templates/teamer/application/index.html.twig +++ b/templates/teamer/application/index.html.twig @@ -62,9 +62,23 @@
- - {{ icon('info', 'w-5 h-5') }} - + {% if is_granted('VIEW', application) %} + + {{ icon('info', 'w-5 h-5') }} + + {% endif %} + {% if is_granted('DELETE', application) %} + + {% endif %}