mirror of
https://github.com/standardebooks/web.git
synced 2025-07-05 22:30:30 -04:00
Tweak how User::$Benefits getter
This commit is contained in:
parent
84f4b2b0bf
commit
e6d4ea1ab6
1 changed files with 15 additions and 16 deletions
11
lib/User.php
11
lib/User.php
|
@ -101,6 +101,7 @@ class User{
|
||||||
|
|
||||||
protected function GetBenefits(): Benefits{
|
protected function GetBenefits(): Benefits{
|
||||||
if(!isset($this->_Benefits)){
|
if(!isset($this->_Benefits)){
|
||||||
|
if(isset($this->UserId)){
|
||||||
$result = Db::Query('
|
$result = Db::Query('
|
||||||
SELECT *
|
SELECT *
|
||||||
from Benefits
|
from Benefits
|
||||||
|
@ -116,6 +117,10 @@ class User{
|
||||||
$this->_IsRegistered = true;
|
$this->_IsRegistered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
$this->_Benefits = new Benefits();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this->_Benefits;
|
return $this->_Benefits;
|
||||||
}
|
}
|
||||||
|
@ -167,12 +172,6 @@ class User{
|
||||||
$this->PasswordHash = null;
|
$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.
|
// 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());
|
$error->Add(new Exceptions\BenefitsRequirePasswordException());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue