mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-19 01:19:31 +00:00
Fixed some inspection issues.
This commit is contained in:
parent
6caf605fe2
commit
e01b06fb85
80 changed files with 173 additions and 218 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue