Skip to content

Commit

Permalink
fix: remove ircmaxell/random-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed May 23, 2024
1 parent 802f703 commit 2e85869
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
],
"require": {
"php": ">=8.1",
"ircmaxell/random-lib": "^1.2",
"symfony/config": "^5.1 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.1 || ^6.0 || ^7.0",
"symfony/event-dispatcher": "^5.1 || ^6.0 || ^7.0",
Expand Down
15 changes: 1 addition & 14 deletions src/Manager/PasswordTokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use CoopTilleuls\ForgotPasswordBundle\Provider\Provider;
use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderChainInterface;
use CoopTilleuls\ForgotPasswordBundle\Provider\ProviderInterface;
use RandomLib\Factory;
use SecurityLib\Strength;

/**
* @author Vincent CHALAMON <[email protected]>
Expand Down Expand Up @@ -49,18 +47,7 @@ public function createPasswordToken($user, ?\DateTime $expiresAt = null, ?Provid

/** @var AbstractPasswordToken $passwordToken */
$passwordToken = new $tokenClass();

if (version_compare(\PHP_VERSION, '7.0', '>')) {
$passwordToken->setToken(bin2hex(random_bytes(25)));
} else {
$factory = new Factory();
$generator = $factory->getGenerator(new Strength(Strength::MEDIUM));

$passwordToken->setToken(
$generator->generateString(50, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
);
}

$passwordToken->setToken(bin2hex(random_bytes(25)));
$passwordToken->setUser($user);
$passwordToken->setExpiresAt($expiresAt);
$provider->getManager()->persist($passwordToken);
Expand Down

0 comments on commit 2e85869

Please sign in to comment.