@@ -40,6 +40,7 @@ namespace common\forms; | |||
use domain\Producer\Producer\Producer; | |||
use domain\User\User\User; | |||
use domain\User\User\UserRepository; | |||
use Yii; | |||
use yii\base\Model; | |||
@@ -122,13 +123,7 @@ class LoginForm extends Model | |||
public function getUser(): ?User | |||
{ | |||
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; |
@@ -213,9 +213,13 @@ class UserRepository extends AbstractRepository | |||
*/ | |||
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 |
@@ -40,6 +40,7 @@ namespace frontend\forms; | |||
use domain\User\User\User; | |||
use domain\User\User\UserModule; | |||
use domain\User\User\UserRepository; | |||
use yii\base\Model; | |||
/** | |||
@@ -70,12 +71,10 @@ class PasswordResetRequestForm extends Model | |||
* | |||
* @return boolean whether the email was send | |||
*/ | |||
public function sendEmail() | |||
public function sendEmail() | |||
{ | |||
$userModule = UserModule::getInstance(); | |||
$user = User::findOne([ | |||
'email' => $this->email, | |||
]); | |||
$user = $userModule->getRepository()->findOneUserByEmail($this->email); | |||
if ($user) { | |||
if (!$userModule->isPasswordResetTokenValid($user->password_reset_token)) { |