mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-01 14:04:30 +02:00
Added permissions for the new functions.
This commit is contained in:
parent
d2bae3a4f2
commit
da14ee942d
14 changed files with 213 additions and 64 deletions
|
@ -30,6 +30,7 @@
|
|||
namespace App\Security\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\Annotation;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use \InvalidArgumentException;
|
||||
|
||||
/**
|
||||
|
@ -65,7 +66,7 @@ class ColumnSecurity
|
|||
|
||||
/**
|
||||
* @var string The name of the property. This is used to determine the default placeholder.
|
||||
* @Annotation\Enum({"integer", "string", "object", "boolean", "datetime"})
|
||||
* @Annotation\Enum({"integer", "string", "object", "boolean", "datetime", "collection"})
|
||||
*/
|
||||
public $type = 'string';
|
||||
|
||||
|
@ -97,6 +98,8 @@ class ColumnSecurity
|
|||
return '???';
|
||||
case 'object':
|
||||
return null;
|
||||
case 'collection':
|
||||
return new ArrayCollection();
|
||||
case 'boolean':
|
||||
return false;
|
||||
case 'datetime':
|
||||
|
|
|
@ -26,10 +26,10 @@ class PartVoter extends ExtendedVoter
|
|||
if (false !== strpos($attribute, '.')) {
|
||||
[$perm, $op] = explode('.', $attribute);
|
||||
|
||||
return in_array($op, $this->resolver->listOperationsForPermission('parts_'.$perm), false);
|
||||
return $this->resolver->isValidOperation('parts_' . $perm, $op);
|
||||
}
|
||||
|
||||
return in_array($attribute, $this->resolver->listOperationsForPermission('parts'), false);
|
||||
return $this->resolver->isValidOperation('parts', $attribute);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -86,11 +86,9 @@ class StructureVoter extends ExtendedVoter
|
|||
case Supplier::class:
|
||||
return 'suppliers';
|
||||
case Currency::class:
|
||||
//TODO: Implement own permission
|
||||
return 'suppliers';
|
||||
return 'currencies';
|
||||
case MeasurementUnit::class:
|
||||
//TODO: Implement own permission
|
||||
return 'suppliers';
|
||||
return 'measurement_units';
|
||||
}
|
||||
//When the class is not supported by this class return null
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue