use domain\Producer\Producer\Producer; | use domain\Producer\Producer\Producer; | ||||
use domain\User\User\User; | use domain\User\User\User; | ||||
use domain\User\User\UserRepository; | |||||
use Yii; | use Yii; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
public function getUser(): ?User | public function getUser(): ?User | ||||
{ | { | ||||
if ($this->_user === false) { | if ($this->_user === false) { | ||||
$this->_user = User::searchOne( | |||||
['email' => $this->email], | |||||
[ | |||||
'conditions' => 'type LIKE :type_individual OR type LIKE :type_legal_person', | |||||
'params' => [':type_individual' => User::TYPE_INDIVIDUAL, ':type_legal_person' => User::TYPE_LEGAL_PERSON] | |||||
] | |||||
); | |||||
$this->_user = UserRepository::getInstance()->findOneUserByEmail($this->email); | |||||
} | } | ||||
return $this->_user; | return $this->_user; |
*/ | */ | ||||
public function findOneUserByEmail(string $email): ?User | public function findOneUserByEmail(string $email): ?User | ||||
{ | { | ||||
return $this->createDefaultQuery() | |||||
->filterByEmail($email) | |||||
->findOne(); | |||||
return User::searchOne( | |||||
['email' => $email], | |||||
[ | |||||
'conditions' => 'type LIKE :type_individual OR type LIKE :type_legal_person', | |||||
'params' => [':type_individual' => User::TYPE_INDIVIDUAL, ':type_legal_person' => User::TYPE_LEGAL_PERSON] | |||||
] | |||||
); | |||||
} | } | ||||
public function findOneUserByUsername(string $username): ?User | public function findOneUserByUsername(string $username): ?User |
use domain\User\User\User; | use domain\User\User\User; | ||||
use domain\User\User\UserModule; | use domain\User\User\UserModule; | ||||
use domain\User\User\UserRepository; | |||||
use yii\base\Model; | use yii\base\Model; | ||||
/** | /** | ||||
* | * | ||||
* @return boolean whether the email was send | * @return boolean whether the email was send | ||||
*/ | */ | ||||
public function sendEmail() | |||||
public function sendEmail() | |||||
{ | { | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$user = User::findOne([ | |||||
'email' => $this->email, | |||||
]); | |||||
$user = $userModule->getRepository()->findOneUserByEmail($this->email); | |||||
if ($user) { | if ($user) { | ||||
if (!$userModule->isPasswordResetTokenValid($user->password_reset_token)) { | if (!$userModule->isPasswordResetTokenValid($user->password_reset_token)) { |