public function testSendNotificationAfterPasswordReset() { DomainEvents::setEventDispatcher(new EventDispatcher()); $user = User::fromDTO(new CreateUserDTO('Ma27', 'test-password', '*****@*****.**')); $publisher = $this->getMock(BackendInterface::class); $publisher->expects($this->once())->method('createAndPublish')->with('sen_mailer', ['user' => $user, 'content' => 'notification.password_reset', 'parameters' => ['translation_defaults' => ['%new_password%' => 'new password']], 'override_locale' => true]); $event = new ResetPasswordEvent($user); $event->setNewRawPassword('new password'); $listener = new PasswordResetListener($publisher); $listener->onPasswordReset($event); }
/** * Hook at the reset password process * * @param ResetPasswordEvent $event */ public function onPasswordReset(ResetPasswordEvent $event) { $this->publisher->createAndPublish('sen_mailer', ['user' => $event->getUser(), 'content' => 'notification.password_reset', 'parameters' => ['translation_defaults' => ['%new_password%' => $event->getNewRawPassword()]], 'override_locale' => true]); }
/** * Resets the password * * @param ActivationKeyCodeGeneratorInterface $stringGenerator */ public function resetPassword(ActivationKeyCodeGeneratorInterface $stringGenerator) { $this->ensureActivated(); $password = $stringGenerator->generateKey(8); $this->credentials = $this->getFactory()->modifyValueObject($this->credentials, ['password' => new Password($password, true)]); $event = new ResetPasswordEvent($this); $event->setNewRawPassword($password); DomainEvents::raise($event); }