Fixed some inspection issues.

This commit is contained in:
Jan Böhmer 2020-08-21 22:43:37 +02:00
parent 6caf605fe2
commit e01b06fb85
80 changed files with 173 additions and 218 deletions

View file

@ -66,7 +66,7 @@ abstract class ExtendedVoter extends Voter
$this->entityManager = $entityManager;
}
final protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
final protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
$user = $token->getUser();

View file

@ -44,7 +44,6 @@ namespace App\Security\Voter;
use App\Entity\Parts\Part;
use App\Entity\UserSystem\User;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
/**
* A Voter that votes on Part entities.

View file

@ -76,16 +76,14 @@ class UserVoter extends ExtendedVoter
*/
protected function voteOnUser($attribute, $subject, User $user): bool
{
if ($subject instanceof User) {
//Check if the checked user is the user itself
if ($subject->getID() === $user->getID() &&
$this->resolver->isValidOperation('self', $attribute)) {
//Then we also need to check the self permission
$tmp = $this->resolver->inherit($user, 'self', $attribute) ?? false;
//But if the self value is not allowed then use just the user value:
if ($tmp) {
return $tmp;
}
//Check if the checked user is the user itself
if (($subject instanceof User) && $subject->getID() === $user->getID() &&
$this->resolver->isValidOperation('self', $attribute)) {
//Then we also need to check the self permission
$tmp = $this->resolver->inherit($user, 'self', $attribute) ?? false;
//But if the self value is not allowed then use just the user value:
if ($tmp) {
return $tmp;
}
}