From d1497981546bedb46c7008f25c7bef0faa9c89cb Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Mon, 25 Nov 2024 11:07:57 -0600 Subject: [PATCH] Another attempt at fixing a reference error --- lib/User.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/User.php b/lib/User.php index 34fcfaf3..c0b3053d 100644 --- a/lib/User.php +++ b/lib/User.php @@ -167,8 +167,14 @@ class User{ $this->PasswordHash = null; } + if(!isset($this->_Benefits)){ + // Set this for validation purposes. + // Skip the accessor because it will attempt to use `$this->UserId` which may not be set yet. + $this->_Benefits = new Benefits(); + } + // Some benefits require this `User` to have a password set. - if($this->Benefits?->RequiresPassword && $this->PasswordHash === null){ + if($this->Benefits->RequiresPassword && $this->PasswordHash === null){ $error->Add(new Exceptions\BenefitsRequirePasswordException()); }