Browse Source

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

feature/rotating_product
Guillaume Bourgeois 6 months ago
parent
commit
f2a394cf13
3 changed files with 12 additions and 14 deletions
  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 View File



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;

+ 7
- 3
domain/User/User/UserRepository.php View File

*/ */
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

+ 3
- 4
frontend/forms/PasswordResetRequestForm.php View File



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

Loading…
Cancel
Save