Skip to content

Commit

Permalink
Fix voter
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Apr 10, 2024
1 parent 356e0f1 commit f415840
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/Security/Voter/AuthorizationVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ protected function voteOnAttribute(string $attribute, mixed $subject, TokenInter

$authToken = $this->getAuthToken($request);

return $this->securityService->checkAuthToken($authToken);
if(!$this->securityService->checkAuthToken($authToken)) {
throw new NotAuthorizedException(
401,
'Full authentication is required.'
);
}
return true;
}
}
6 changes: 3 additions & 3 deletions src/Security/Voter/PublicAuthorizationVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ protected function supports(string $attribute, mixed $subject): bool
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
{
$request = $this->getCurrentRequest($this->requestStack);

$subjectName = $this->getSubjectName($subject);
try {
$authToken = $this->getAuthToken($request);
} catch (NotAuthorizedException) {
return $this->voteOnRequest($request, $this->getSubjectName($subject));
return $this->voteOnRequest($request, $subjectName);
}

if ($this->securityService->checkAuthToken($authToken)) {
return true;
}

return $this->voteOnRequest($request, $subject);
return $this->voteOnRequest($request, $subjectName);
}

/**
Expand Down

0 comments on commit f415840

Please sign in to comment.