Fix the $permissions must be initialized before access exception preventing login on two factor auth

This commit is contained in:
Jan Böhmer 2022-11-28 00:03:42 +01:00
parent fc27728c62
commit 75cf3dc46f
2 changed files with 11 additions and 3 deletions

View file

@ -96,11 +96,11 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
protected $attachments; protected $attachments;
/** /**
* @var PermissionData * @var PermissionData|null
* @ValidPermission() * @ValidPermission()
* @ORM\Embedded(class="PermissionData", columnPrefix="permissions_") * @ORM\Embedded(class="PermissionData", columnPrefix="permissions_")
*/ */
protected PermissionData $permissions; protected ?PermissionData $permissions = null;
/** @var Collection<int, GroupParameter> /** @var Collection<int, GroupParameter>
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\GroupParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) * @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 public function getPermissions(): PermissionData
{ {
if ($this->permissions === null) {
$this->permissions = new PermissionData();
}
return $this->permissions; return $this->permissions;
} }

View file

@ -265,7 +265,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
* @ValidPermission() * @ValidPermission()
* @ORM\Embedded(class="PermissionData", columnPrefix="permissions_") * @ORM\Embedded(class="PermissionData", columnPrefix="permissions_")
*/ */
protected PermissionData $permissions; protected ?PermissionData $permissions = null;
/** /**
* @var DateTime the time until the password reset token is valid * @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 public function getPermissions(): PermissionData
{ {
if ($this->permissions === null) {
$this->permissions = new PermissionData();
}
return $this->permissions; return $this->permissions;
} }