From 75cf3dc46f61413f3727432a36645092d34f6ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 28 Nov 2022 00:03:42 +0100 Subject: [PATCH] Fix the $permissions must be initialized before access exception preventing login on two factor auth --- src/Entity/UserSystem/Group.php | 8 ++++++-- src/Entity/UserSystem/User.php | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php index bb651a11..5aee4cb6 100644 --- a/src/Entity/UserSystem/Group.php +++ b/src/Entity/UserSystem/Group.php @@ -96,11 +96,11 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa protected $attachments; /** - * @var PermissionData + * @var PermissionData|null * @ValidPermission() * @ORM\Embedded(class="PermissionData", columnPrefix="permissions_") */ - protected PermissionData $permissions; + protected ?PermissionData $permissions = null; /** @var Collection * @ORM\OneToMany(targetEntity="App\Entity\Parameters\GroupParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) @@ -140,6 +140,10 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa public function getPermissions(): PermissionData { + if ($this->permissions === null) { + $this->permissions = new PermissionData(); + } + return $this->permissions; } diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 72db01a4..69c7afb2 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -265,7 +265,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe * @ValidPermission() * @ORM\Embedded(class="PermissionData", columnPrefix="permissions_") */ - protected PermissionData $permissions; + protected ?PermissionData $permissions = null; /** * @var DateTime the time until the password reset token is valid @@ -425,6 +425,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe public function getPermissions(): PermissionData { + if ($this->permissions === null) { + $this->permissions = new PermissionData(); + } + return $this->permissions; }