common\models\User::findByPasswordResetToken PHP Method

findByPasswordResetToken() public static method

Finds user by password reset token
public static findByPasswordResetToken ( string $token ) : static | null
$token string password reset token
return static | null
    public static function findByPasswordResetToken($token)
    {
        if (!static::isPasswordResetTokenValid($token)) {
            return null;
        }
        return static::findOne(['password_reset_token' => $token, 'status' => self::STATUS_ACTIVE]);
    }

Usage Example

 /**
  * Creates a form model given a token.
  *
  * @param  string                          $token
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($token, $config = [])
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException('Password reset token cannot be blank.');
     }
     $this->user = User::findByPasswordResetToken($token);
     if (!$this->user) {
         throw new InvalidParamException('Wrong password reset token.');
     }
     parent::__construct($config);
 }
All Usage Examples Of common\models\User::findByPasswordResetToken