Skip to content

Commit

Permalink
Compute changeSet only for the history class
Browse files Browse the repository at this point in the history
Some readme additions.
  • Loading branch information
lsimeonov committed Jul 31, 2018
1 parent 36fc6e9 commit 0beb8d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ password_policy:

##### Expiry
Expiry works by checking last password change on every request made to the app, excluding those configured in the application

##### Good to know
The library uses doctrine lifecycle events to create password history and set last password change on the target entities.
In order for this to happen we use the onFlush event and we are recalculating the history change set inside it.
You must be aware of that as any entity changes after the recalculation will not be persisted to the database.
4 changes: 3 additions & 1 deletion src/EventListener/PasswordEntityListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ public function createPasswordHistory(
}

$em->persist($history);
$uow->computeChangeSets();

$metadata = $em->getClassMetadata($historyClass);
$uow->computeChangeSet($metadata, $history);

$entity->setPasswordChangedAt(new \DateTime());

Expand Down

0 comments on commit 0beb8d6

Please sign in to comment.