Fix: Check higher permissions first

This commit is contained in:
Björn Fromme
2023-10-12 12:38:56 +02:00
parent f0a16d01d7
commit b0f57cdcaa
+8 -8
View File
@@ -31,14 +31,6 @@ 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 => true,
@@ -48,6 +40,14 @@ class ApplicationVoter extends Voter
};
}
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,
};
}
return false;
}
}