mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-27 05:19:31 +00:00
Allow to show what permissions a user is lacking in case of access denied message
Should help with errors like 1026
This commit is contained in:
parent
ba7d139f8a
commit
117ff4484d
3 changed files with 35 additions and 6 deletions
|
|
@ -24,6 +24,7 @@ namespace App\Security\Voter;
|
|||
|
||||
use App\Services\UserSystem\VoterHelper;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
/**
|
||||
|
|
@ -39,12 +40,17 @@ final class PermissionVoter extends Voter
|
|||
|
||||
}
|
||||
|
||||
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
|
||||
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool
|
||||
{
|
||||
$attribute = ltrim($attribute, '@');
|
||||
[$perm, $op] = explode('.', $attribute);
|
||||
|
||||
return $this->helper->isGranted($token, $perm, $op);
|
||||
$result = $this->helper->isGranted($token, $perm, $op);
|
||||
if ($result === false) {
|
||||
$this->helper->addReason($vote, $perm, $op);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function supportsAttribute(string $attribute): bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue