This commit is contained in:
Julie Lenaerts 2022-03-10 14:54:03 +01:00
parent a3c5cabc9a
commit c34c8035ea
4 changed files with 32 additions and 25 deletions

View File

@ -112,6 +112,11 @@ class User implements AdvancedUserInterface
*/ */
private string $password = ''; private string $password = '';
/**
* @ORM\Column(type="json")
*/
private array $roles = ['ROLE_USER'];
/** /**
* @internal must be set to null if we use bcrypt * @internal must be set to null if we use bcrypt
* *
@ -138,11 +143,6 @@ class User implements AdvancedUserInterface
*/ */
private ?string $usernameCanonical = null; private ?string $usernameCanonical = null;
/**
* @ORM\Column(type="json")
*/
private array $roles = ['ROLE_USER'];
/** /**
* User constructor. * User constructor.
*/ */
@ -156,6 +156,13 @@ class User implements AdvancedUserInterface
return $this->getLabel(); return $this->getLabel();
} }
public function addGroupCenter(GroupCenter $groupCenter): self
{
$this->groupCenters->add($groupCenter);
return $this;
}
// empty function... remove? // empty function... remove?
public function eraseCredentials() public function eraseCredentials()
{ {
@ -300,13 +307,6 @@ class User implements AdvancedUserInterface
} }
} }
public function addGroupCenter(GroupCenter $groupCenter): self
{
$this->groupCenters->add($groupCenter);
return $this;
}
/** /**
* Set attributes. * Set attributes.
* *
@ -328,12 +328,6 @@ class User implements AdvancedUserInterface
return $this; return $this;
} }
public function setRoles($roles): self
{
$this->roles = $roles;
return $this;
}
public function setEmail($email): self public function setEmail($email): self
{ {
$this->email = $email; $this->email = $email;
@ -390,6 +384,13 @@ class User implements AdvancedUserInterface
return $this; return $this;
} }
public function setRoles($roles): self
{
$this->roles = $roles;
return $this;
}
public function setSalt($salt): self public function setSalt($salt): self
{ {
$this->salt = $salt; $this->salt = $salt;

View File

@ -65,7 +65,7 @@ class UserType extends AbstractType
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
'label' => 'Roles', 'label' => 'Roles',
'choices' => [ 'choices' => [
'Usager' => 'ROLE_USER', 'Usager' => 'ROLE_USER',
'Administrateur' => 'ROLE_ADMIN', 'Administrateur' => 'ROLE_ADMIN',
], ],

View File

@ -64,7 +64,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
] ]
); );
if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) { if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) {
$menu->addChild($this->translator->trans('Export Menu'), [ $menu->addChild($this->translator->trans('Export Menu'), [
'route' => 'chill_main_export_index', 'route' => 'chill_main_export_index',

View File

@ -1,5 +1,12 @@
<?php <?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1); declare(strict_types=1);
namespace Chill\Migrations\Main; namespace Chill\Migrations\Main;
@ -12,6 +19,11 @@ use Doctrine\Migrations\AbstractMigration;
*/ */
final class Version20220308104030 extends AbstractMigration final class Version20220308104030 extends AbstractMigration
{ {
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE users DROP roles');
}
public function getDescription(): string public function getDescription(): string
{ {
return 'Add roles property to user'; return 'Add roles property to user';
@ -21,9 +33,4 @@ final class Version20220308104030 extends AbstractMigration
{ {
$this->addSql('ALTER TABLE users ADD roles JSONB DEFAULT \'["ROLE_USER"]\' NOT NULL'); $this->addSql('ALTER TABLE users ADD roles JSONB DEFAULT \'["ROLE_USER"]\' NOT NULL');
} }
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE users DROP roles');
}
} }