Browse Source

Correctif

refactoring
Guillaume Bourgeois 1 year ago
parent
commit
aa4705beba
2 changed files with 5 additions and 3 deletions
  1. +1
    -1
      common/logic/User/User/Service/UserSolver.php
  2. +4
    -2
      frontend/forms/PasswordResetRequestForm.php

+ 1
- 1
common/logic/User/User/Service/UserSolver.php View File

@@ -75,7 +75,7 @@ class UserSolver extends AbstractService implements SolverInterface
* @param string $token password reset token
* @return boolean
*/
public static function isPasswordResetTokenValid($token)
public function isPasswordResetTokenValid($token)
{
if (empty($token)) {
return false;

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

@@ -40,6 +40,7 @@ namespace frontend\forms;

use common\logic\User\User\Model\User;
use common\logic\User\User\Service\UserSolver;
use common\logic\User\User\Wrapper\UserManager;
use yii\base\Model;
use yii;

@@ -73,13 +74,14 @@ class PasswordResetRequestForm extends Model
*/
public function sendEmail()
{
$userManager = UserManager::getInstance();
$user = User::findOne([
'email' => $this->email,
]);

if ($user) {
if (!UserSolver::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
if (!$userManager->isPasswordResetTokenValid($user->password_reset_token)) {
$userManager->generatePasswordResetToken($user);
}

if ($user->save()) {

Loading…
Cancel
Save