chore: code cleanup
This commit is contained in:
@@ -30,7 +30,7 @@ class BpnAuthenticator extends AbstractLoginFormAuthenticator implements Authent
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly UserDataHandler $userDataHandler
|
||||
private readonly UserDataHandler $userDataHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class BpnAuthenticator extends AbstractLoginFormAuthenticator implements Authent
|
||||
ProfileResponse $profileResponse,
|
||||
string $email,
|
||||
string $password,
|
||||
?string $preferredRole
|
||||
?string $preferredRole,
|
||||
): ?User {
|
||||
// Fetch CRM attributes, early return in case of an API error
|
||||
try {
|
||||
|
||||
@@ -43,6 +43,7 @@ class ApplicationVoter extends Voter
|
||||
|
||||
if ($this->security->isGranted('ROLE_ADMINISTRATIVE') && in_array($attribute, $adminAttributes)) {
|
||||
$assignment = $application->getAssignment();
|
||||
|
||||
return match ($attribute) {
|
||||
static::STATUS, static::DELETE => true,
|
||||
static::VIEW => Application::STATUS_REJECTED !== $status,
|
||||
@@ -68,4 +69,4 @@ class ApplicationVoter extends Voter
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Security\Voter;
|
||||
|
||||
use App\Entity\Application;
|
||||
use App\Entity\Assignment;
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
@@ -21,7 +20,7 @@ class AssignmentVoter extends Voter
|
||||
|
||||
public function __construct(
|
||||
private readonly Security $security,
|
||||
private readonly EntityManagerInterface $entityManager
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ class AvailabilityVoter extends Voter
|
||||
public const DELETE = 'DELETE';
|
||||
|
||||
public function __construct(private readonly Security $security)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
protected function supports(string $attribute, mixed $subject): bool
|
||||
{
|
||||
@@ -45,4 +46,4 @@ class AvailabilityVoter extends Voter
|
||||
|
||||
return null === $availability->getOwner() || $teamer === $availability->getOwner();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@ class DispositionVoter extends Voter
|
||||
$disposition = $subject;
|
||||
|
||||
return match ($attribute) {
|
||||
static::VIEW, static::EDIT, static::CONTRACT, static::INVOICE =>
|
||||
$this->security->isGranted('ROLE_ADMINISTRATIVE')
|
||||
static::VIEW, static::EDIT, static::CONTRACT, static::INVOICE => $this->security->isGranted('ROLE_ADMINISTRATIVE')
|
||||
|| $this->assertTeamerAccess($token, $disposition),
|
||||
static::DELETE => $this->security->isGranted('ROLE_ADMIN'),
|
||||
static::FEEDBACK => $this->security->isGranted('ROLE_ADMINISTRATIVE')
|
||||
|
||||
@@ -33,4 +33,4 @@ class FeedbackSetVoter extends Voter
|
||||
|
||||
return null === $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,4 +41,4 @@ class FeedbackVoter extends Voter
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ class LicenseVoter extends Voter
|
||||
public const DELETE = 'DELETE';
|
||||
|
||||
public function __construct(private readonly Security $security)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
protected function supports(string $attribute, mixed $subject): bool
|
||||
{
|
||||
@@ -38,4 +39,4 @@ class LicenseVoter extends Voter
|
||||
|
||||
return $license->getTeamer() === $user->getTeamer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class UploadVoter extends Voter
|
||||
|
||||
protected function supports(string $attribute, mixed $subject): bool
|
||||
{
|
||||
if (! $subject instanceof Upload) {
|
||||
if (!$subject instanceof Upload) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user