Skip to content

Commit

Permalink
Merge pull request #126 from szymach/3.2
Browse files Browse the repository at this point in the history
Fixed new activation token not being persisted to database
  • Loading branch information
rn0 authored Oct 14, 2019
2 parents 8b200a3 + bd1c648 commit 536182b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions EventListener/PersistDoctrineUserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static function getSubscribedEvents(): array
AdminSecurityEvents::CHANGE_PASSWORD => 'onChangePassword',
AdminSecurityEvents::RESET_PASSWORD_REQUEST => 'onResetPasswordRequest',
AdminSecurityEvents::ACTIVATION => 'onActivation',
AdminSecurityEvents::RESEND_ACTIVATION_TOKEN => 'onActivationResend',
AdminSecurityEvents::DEACTIVATION => 'onDeactivation',
AdminSecurityEvents::USER_CREATED => 'onUserCreated',
AdminSecurityEvents::PROMOTE_USER => 'onPromoteUser',
Expand All @@ -53,6 +54,11 @@ public function onActivation(ActivationEvent $event): void
$this->flushUserObjectManager($event->getUser());
}

public function onActivationResend(ActivationEvent $event): void
{
$this->flushUserObjectManager($event->getUser());
}

public function onDeactivation(ActivationEvent $event): void
{
$this->flushUserObjectManager($event->getUser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function it_subscribes_all_events()
AdminSecurityEvents::CHANGE_PASSWORD => 'onChangePassword',
AdminSecurityEvents::RESET_PASSWORD_REQUEST => 'onResetPasswordRequest',
AdminSecurityEvents::ACTIVATION => 'onActivation',
AdminSecurityEvents::RESEND_ACTIVATION_TOKEN => 'onActivationResend',
AdminSecurityEvents::DEACTIVATION => 'onDeactivation',
AdminSecurityEvents::USER_CREATED => 'onUserCreated',
AdminSecurityEvents::PROMOTE_USER => 'onPromoteUser',
Expand Down Expand Up @@ -86,6 +87,19 @@ function it_flushes_om_after_activation(
$this->onActivation($event);
}

function it_flushes_om_after_resending_activation_token(
ActivationEvent $event,
ObjectManager $objectManager,
User $user
) {
$event->getUser()->willReturn($user);

$objectManager->persist($user)->shouldBeCalled();
$objectManager->flush()->shouldBeCalled();

$this->onActivationResend($event);
}

function it_flushes_om_after_deactivation(
ActivationEvent $event,
ObjectManager $objectManager,
Expand Down

0 comments on commit 536182b

Please sign in to comment.