mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-22 19:09:31 +00:00
Use anonymous user permissions, if nobody is logged in.
This commit is contained in:
parent
9d0dde3df3
commit
4d39d5cfb7
3 changed files with 108 additions and 14 deletions
|
|
@ -18,16 +18,10 @@ use Symfony\Component\Security\Core\User\UserInterface;
|
|||
*
|
||||
* @package App\Security\Voter
|
||||
*/
|
||||
class PartVoter extends Voter
|
||||
class PartVoter extends ExtendedVoter
|
||||
{
|
||||
const READ = "read";
|
||||
|
||||
protected $resolver;
|
||||
|
||||
public function __construct(PermissionResolver $resolver)
|
||||
{
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
|
|
@ -43,14 +37,9 @@ class PartVoter extends Voter
|
|||
return false;
|
||||
}
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||
{
|
||||
$user = $token->getUser();
|
||||
// if the user is anonymous, do not grant access
|
||||
if (!$user instanceof User) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
{
|
||||
if($subject instanceof Part) {
|
||||
//Null concealing operator means, that no
|
||||
return $this->resolver->inherit($user, 'parts', $attribute) ?? false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue