From 4d013a4550234dbbccc74e25cc582c61306bcb04 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sat, 16 Apr 2022 23:28:05 +0200 Subject: [PATCH] add ROLE_MANAGER --- config/packages/security.yaml | 3 ++- src/Entity/User.php | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 9665acd..ab24957 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -13,7 +13,8 @@ security: role_hierarchy: ROLE_WRITER: ROLE_USER - ROLE_ADMIN: ROLE_WRITER + ROLE_MANAGER: ROLE_WRITER + ROLE_ADMIN: ROLE_MANAGER firewalls: dev: diff --git a/src/Entity/User.php b/src/Entity/User.php index 4e1fba0..7f6a251 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -70,6 +70,11 @@ class User implements PasswordAuthenticatedUserInterface, UserInterface, TwoFact */ protected $isWriter; + /** + * @ORM\Column(type="boolean", nullable=true) + */ + protected $isManager; + public function __construct() { } @@ -118,6 +123,10 @@ class User implements PasswordAuthenticatedUserInterface, UserInterface, TwoFact $roles[] = 'ROLE_ADMIN'; } + if ($this->getIsManager()) { + $roles[] = 'ROLE_MANAGER'; + } + return array_unique($roles); } @@ -247,4 +256,16 @@ class User implements PasswordAuthenticatedUserInterface, UserInterface, TwoFact return $this; } + + public function getIsManager(): ?bool + { + return $this->isManager; + } + + public function setIsManager(?bool $isManager): self + { + $this->isManager = $isManager; + + return $this; + } }