浏览代码

fix makeAdminAccess method

Olivier Massot 1 年之前
父节点
当前提交
876215b11a
共有 3 个文件被更改,包括 37 次插入3 次删除
  1. 14 0
      src/Entity/Access/Access.php
  2. 14 0
      src/Entity/Person/Person.php
  3. 9 3
      src/Service/Organization/OrganizationFactory.php

+ 14 - 0
src/Entity/Access/Access.php

@@ -112,6 +112,9 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
     #[ORM\Column(type: 'json', length: 4294967295, nullable: true)]
     private ?array $roles = [];
 
+    #[ORM\Column(options: ['default' => false])]
+    private bool $loginEnabled = false;
+
     /** @var mixed[]|null */
     #[Groups(['my_access:input'])]
     #[ORM\Column(type: 'json', length: 4294967295, nullable: true)]
@@ -493,6 +496,17 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
         return array_unique($roles ?? []);
     }
 
+    public function isLoginEnabled(): bool
+    {
+        return $this->loginEnabled;
+    }
+
+    public function setLoginEnabled(bool $loginEnabled): self
+    {
+        $this->loginEnabled = $loginEnabled;
+        return $this;
+    }
+
     public function getPersonActivity(): Collection
     {
         return $this->personActivity;

+ 14 - 0
src/Entity/Person/Person.php

@@ -42,6 +42,9 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
     #[ORM\Column(length: 180, unique: true, nullable: true)]
     private ?string $username = null;
 
+    #[ORM\Column(options: ['default' => false])]
+    private bool $enabled = false;
+
     /**
      * @var array<mixed>|null
      */
@@ -151,6 +154,17 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
         return $this;
     }
 
+    public function isEnabled(): bool
+    {
+        return $this->enabled;
+    }
+
+    public function setEnabled(bool $enabled): self
+    {
+        $this->enabled = $enabled;
+        return $this;
+    }
+
     /**
      * @return string[]
      */

+ 9 - 3
src/Service/Organization/OrganizationFactory.php

@@ -521,13 +521,20 @@ class OrganizationFactory
         $admin->setUsername('admin'.strtolower($organizationCreationRequest->getSubdomain()));
         $randomString = ByteString::fromRandom(32)->toString();
         $admin->setPassword($randomString);
+        $admin->setEnabled(true);
 
         $adminAccess = new Access();
         $adminAccess->setAdminAccess(true);
         $adminAccess->setPerson($admin);
+        $adminAccess->setLoginEnabled(true);
         $adminAccess->setCreateDate($organizationCreationRequest->getCreationDate());
         $adminAccess->setCreatedBy($organizationCreationRequest->getAuthorId());
 
+        $contactPoint = new ContactPoint();
+        $contactPoint->setContactType(ContactPointTypeEnum::PRINCIPAL);
+        $contactPoint->setEmail($organizationCreationRequest->getEmail());
+        $admin->addContactPoint($contactPoint);
+
         return $adminAccess;
     }
 
@@ -649,8 +656,7 @@ class OrganizationFactory
      */
     protected function makePersonContactPoint(OrganizationMemberCreationRequest $organizationMemberCreationRequest): ContactPoint
     {
-        $phoneUtil = PhoneNumberUtil::getInstance();
-        $phoneNumber = $phoneUtil->parse($organizationMemberCreationRequest->getPhone());
+        $phoneNumber = $this->phoneNumberUtil->parse($organizationMemberCreationRequest->getPhone());
 
         $contactPoint = new ContactPoint();
         $contactPoint->setContactType(ContactPointTypeEnum::PRINCIPAL);
@@ -658,7 +664,7 @@ class OrganizationFactory
         $contactPoint->setTelphone($phoneNumber);
 
         if ($organizationMemberCreationRequest->getMobile() !== null) {
-            $mobileNumber = $phoneUtil->parse($organizationMemberCreationRequest->getMobile());
+            $mobileNumber = $this->phoneNumberUtil->parse($organizationMemberCreationRequest->getMobile());
             $contactPoint->setMobilPhone($mobileNumber);
         }