mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 01:52:02 -04:00
Correctly process matching donations from funds
This commit is contained in:
parent
daee86b919
commit
06096fa7dd
4 changed files with 19 additions and 14 deletions
19
lib/User.php
19
lib/User.php
|
@ -189,11 +189,16 @@ class User{
|
|||
/**
|
||||
* @throws Exceptions\InvalidUserException
|
||||
*/
|
||||
public function Validate(): void{
|
||||
public function Validate(bool $requireEmail): void{
|
||||
$error = new Exceptions\InvalidUserException();
|
||||
|
||||
if(!isset($this->Email)){
|
||||
$error->Add(new Exceptions\EmailRequiredException());
|
||||
if(trim($this->Email ?? '') == ''){
|
||||
if($requireEmail){
|
||||
$error->Add(new Exceptions\EmailRequiredException());
|
||||
}
|
||||
else{
|
||||
$this->Email = null;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(filter_var($this->Email, FILTER_VALIDATE_EMAIL) === false){
|
||||
|
@ -238,10 +243,10 @@ class User{
|
|||
* @throws Exceptions\InvalidUserException
|
||||
* @throws Exceptions\UserExistsException
|
||||
*/
|
||||
public function Create(?string $password = null): void{
|
||||
public function Create(?string $password = null, bool $requireEmail = true): void{
|
||||
$this->GenerateUuid();
|
||||
|
||||
$this->Validate();
|
||||
$this->Validate($requireEmail);
|
||||
|
||||
$this->Created = NOW;
|
||||
|
||||
|
@ -270,8 +275,8 @@ class User{
|
|||
* @throws Exceptions\InvalidUserException
|
||||
* @throws Exceptions\UserExistsException
|
||||
*/
|
||||
public function Save(): void{
|
||||
$this->Validate();
|
||||
public function Save(bool $requireEmail = true): void{
|
||||
$this->Validate($requireEmail);
|
||||
|
||||
$this->Updated = NOW;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue