Skip to content

Commit

Permalink
Merge branch '2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Jun 15, 2019
2 parents d9ed1b9 + b1815d6 commit e18bffb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions behat.yml.dist
Expand Up @@ -5,6 +5,7 @@ default:
- 'CommandContext'
- 'DoctrineContext':
doctrine: '@doctrine'
passwordEncoder: '@security.password_encoder'
- 'HttpHeaderContext'
- 'GraphqlContext'
- 'JsonContext'
Expand Down Expand Up @@ -42,6 +43,7 @@ postgres:
- 'CommandContext'
- 'DoctrineContext':
doctrine: '@doctrine'
passwordEncoder: '@security.password_encoder'
- 'HttpHeaderContext'
- 'GraphqlContext'
- 'JsonContext'
Expand All @@ -66,6 +68,7 @@ mongodb:
- 'CommandContext'
- 'DoctrineContext':
doctrine: '@doctrine_mongodb'
passwordEncoder: '@security.password_encoder'
- 'HttpHeaderContext'
- 'GraphqlContext'
- 'JsonContext'
Expand Down Expand Up @@ -108,6 +111,7 @@ default-coverage:
- 'CommandContext'
- 'DoctrineContext':
doctrine: '@doctrine'
passwordEncoder: '@security.password_encoder'
- 'HttpHeaderContext'
- 'GraphqlContext'
- 'JsonContext'
Expand All @@ -133,6 +137,7 @@ mongodb-coverage:
- 'CommandContext'
- 'DoctrineContext':
doctrine: '@doctrine_mongodb'
passwordEncoder: '@security.password_encoder'
- 'HttpHeaderContext'
- 'GraphqlContext'
- 'JsonContext'
Expand Down
8 changes: 5 additions & 3 deletions features/bootstrap/DoctrineContext.php
Expand Up @@ -127,6 +127,7 @@
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\SchemaTool;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;

/**
* Defines application features from the specific context.
Expand All @@ -138,6 +139,7 @@ final class DoctrineContext implements Context
*/
private $manager;
private $doctrine;
private $passwordEncoder;
private $schemaTool;
private $schemaManager;
private $classes;
Expand All @@ -149,9 +151,10 @@ final class DoctrineContext implements Context
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct(ManagerRegistry $doctrine)
public function __construct(ManagerRegistry $doctrine, UserPasswordEncoderInterface $passwordEncoder)
{
$this->doctrine = $doctrine;
$this->passwordEncoder = $passwordEncoder;
$this->manager = $doctrine->getManager();
$this->schemaTool = $this->manager instanceof EntityManagerInterface ? new SchemaTool($this->manager) : null;
$this->schemaManager = $this->manager instanceof DocumentManager ? $this->manager->getSchemaManager() : null;
Expand Down Expand Up @@ -1066,8 +1069,7 @@ public function thereAreNodesInAContainer(int $nb, string $uuid)
public function thePasswordForUserShouldBeHashed(string $password, string $user)
{
$user = $this->doctrine->getRepository($this->isOrm() ? User::class : UserDocument::class)->find($user);

if (!password_verify($password, $user->getPassword())) {
if (!$this->passwordEncoder->isPasswordValid($user, $password)) {
throw new \Exception('User password mismatch');
}
}
Expand Down

0 comments on commit e18bffb

Please sign in to comment.