Skip to content

Commit

Permalink
PasswordEncoder -> PasswordHasher
Browse files Browse the repository at this point in the history
  • Loading branch information
chihiro-adachi committed Dec 14, 2023
1 parent 1cd2d29 commit d6b1ed1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Eccube/Command/LoadDataFixturesEccubeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand;
use Doctrine\Persistence\ManagerRegistry;
use Eccube\Common\EccubeConfig;
use Eccube\Security\PasswordHasher\PasswordHasher;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
Expand All @@ -29,10 +30,16 @@ class LoadDataFixturesEccubeCommand extends DoctrineCommand
*/
protected $eccubeConfig;

public function __construct(ManagerRegistry $registry, EccubeConfig $eccubeConfig)
/**
* @var PasswordHasher
*/
protected $passwordHasher;

public function __construct(ManagerRegistry $registry, EccubeConfig $eccubeConfig, PasswordHasher $passwordHasher)
{
parent::__construct($registry);
$this->eccubeConfig = $eccubeConfig;
$this->passwordHasher = $passwordHasher;
}

protected function configure()
Expand Down Expand Up @@ -66,10 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$login_id = env('ECCUBE_ADMIN_USER', 'admin');
$login_password = env('ECCUBE_ADMIN_PASS', 'password');

$encoder = new \Eccube\Security\Core\Encoder\PasswordEncoder($eccubeConfig);

$salt = \Eccube\Util\StringUtil::random(32);
$password = $encoder->encodePassword($login_password, $salt);
$password = $this->passwordHasher->hash($login_password);

$conn = $em->getConnection();
$member_id = ('postgresql' === $conn->getDatabasePlatform()->getName())
Expand All @@ -80,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'id' => $member_id,
'login_id' => $login_id,
'password' => $password,
'salt' => $salt,
'salt' => 'n/a',
'work_id' => 1,
'authority_id' => 0,
'creator_id' => 1,
Expand Down

0 comments on commit d6b1ed1

Please sign in to comment.