From 99b25e3abb275a8491ae1dcb5b0b609f9cd5ca22 Mon Sep 17 00:00:00 2001 From: Jean-Francois Monfort Date: Thu, 4 Mar 2021 11:38:03 +0100 Subject: [PATCH] Add new field attributes to user to store data from SAML connection --- Entity/User.php | 36 +++++++++++++++++++++++++++- migrations/Version20210304085819.php | 30 +++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 migrations/Version20210304085819.php diff --git a/Entity/User.php b/Entity/User.php index d77883200..1a46b30a5 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -100,7 +100,14 @@ class User implements AdvancedUserInterface { * @ORM\Cache(usage="NONSTRICT_READ_WRITE") */ private $groupCenters; - + + /** + * Array where SAML attributes's data are stored + * @var array + * + * @ORM\Column(type="json_array", nullable=true) + */ + private $attributes; /** * User constructor. @@ -346,4 +353,31 @@ class User implements AdvancedUserInterface { } } + /** + * Set attributes + * + * @param array $attributes + * + * @return Report + */ + public function setAttributes($attributes) + { + $this->attributes = $attributes; + + return $this; + } + + /** + * Get attributes + * + * @return array + */ + public function getAttributes() + { + if ($this->attributes === null) { + $this->attributes = []; + } + + return $this->attributes; + } } diff --git a/migrations/Version20210304085819.php b/migrations/Version20210304085819.php new file mode 100644 index 000000000..48b54919e --- /dev/null +++ b/migrations/Version20210304085819.php @@ -0,0 +1,30 @@ +addSql('ALTER TABLE users ADD attributes JSONB DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN users.attributes IS \'(DC2Type:json_array)\''); + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE users DROP attributes'); + } +}