mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 10:49:00 +02:00
Added a simple Voter for checking, if a user is allowed, to view/edit/create a part.
This commit is contained in:
parent
ab3f5db174
commit
01e1f27b68
10 changed files with 750 additions and 4 deletions
|
@ -32,6 +32,8 @@
|
|||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Embeddables\PermissionEntity;
|
||||
use App\Security\Interfaces\HasPermissionsInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
@ -43,7 +45,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
|
||||
* @ORM\Table("users")
|
||||
*/
|
||||
class User extends NamedDBElement implements UserInterface
|
||||
class User extends NamedDBElement implements UserInterface, HasPermissionsInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
|
@ -115,11 +117,16 @@ class User extends NamedDBElement implements UserInterface
|
|||
|
||||
/**
|
||||
* @var Group|null The group this user belongs to.
|
||||
* @ORM\ManyToOne(targetEntity="Group", inversedBy="users")
|
||||
* @ORM\ManyToOne(targetEntity="Group", inversedBy="users", fetch="EAGER")
|
||||
* @ORM\JoinColumn(name="group_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $group;
|
||||
|
||||
/** @var PermissionsEmbed
|
||||
* @ORM\Embedded(class="PermissionsEmbed", columnPrefix="perms_")
|
||||
*/
|
||||
protected $permissions;
|
||||
|
||||
|
||||
/**
|
||||
* A visual identifier that represents this user.
|
||||
|
@ -200,6 +207,11 @@ class User extends NamedDBElement implements UserInterface
|
|||
}
|
||||
|
||||
|
||||
public function getPermissions() : PermissionsEmbed
|
||||
{
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
/************************************************
|
||||
* Getters
|
||||
************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue