Переглянути джерело

[Site] Mot de passe oublié : correctif envoi impossible de l'email avec lien de réinitialisation

feature/rotating_product
Guillaume Bourgeois 6 місяці тому
джерело
коміт
f2a394cf13
3 змінених файлів з 12 додано та 14 видалено
  1. +2
    -7
      common/forms/LoginForm.php
  2. +7
    -3
      domain/User/User/UserRepository.php
  3. +3
    -4
      frontend/forms/PasswordResetRequestForm.php

+ 2
- 7
common/forms/LoginForm.php Переглянути файл

@@ -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;

+ 7
- 3
domain/User/User/UserRepository.php Переглянути файл

@@ -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

+ 3
- 4
frontend/forms/PasswordResetRequestForm.php Переглянути файл

@@ -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)) {

Завантаження…
Відмінити
Зберегти