mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-23 10:18:56 +02:00
Fixed some exception about non existing part_attachments permission
This commit is contained in:
parent
3e85fc4d42
commit
676235a2d3
3 changed files with 6 additions and 4 deletions
|
@ -106,7 +106,7 @@ class AttachmentFormType extends AbstractType
|
|||
'required' => false,
|
||||
'label' => 'attachment.edit.secure_file',
|
||||
'mapped' => false,
|
||||
'disabled' => !$this->security->isGranted('@parts_attachments.show_private'),
|
||||
'disabled' => !$this->security->isGranted('@attachments.show_private'),
|
||||
'help' => 'attachment.edit.secure_file.help',
|
||||
]);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class AttachmentVoter extends ExtendedVoter
|
|||
*/
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
return $this->resolver->inherit($user, 'parts_attachments', $attribute) ?? false;
|
||||
return $this->resolver->inherit($user, 'attachments', $attribute) ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +70,7 @@ class AttachmentVoter extends ExtendedVoter
|
|||
protected function supports(string $attribute, $subject): bool
|
||||
{
|
||||
if (is_a($subject, Attachment::class, true)) {
|
||||
return in_array($attribute, $this->resolver->listOperationsForPermission('parts_attachments'), false);
|
||||
return in_array($attribute, $this->resolver->listOperationsForPermission('attachments'), false);
|
||||
}
|
||||
|
||||
//Allow class name as subject
|
||||
|
|
|
@ -83,7 +83,9 @@ class PermissionVoter extends ExtendedVoter
|
|||
$valid = $this->resolver->isValidOperation($perm, $op);
|
||||
|
||||
//if an invalid operation is encountered, throw an exception so the developer knows it
|
||||
//throw new \RuntimeException('Encountered invalid permission operation "'.$op.'" for permission "'.$perm.'"!');
|
||||
if(!$valid) {
|
||||
throw new \RuntimeException('Encountered invalid permission operation "'.$op.'" for permission "'.$perm.'"!');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue