/** * @todo remove unused $mailer parameter an fix tests * * @param InputFilterInterface $filter * @param Plugin\Mailer $mailer * @param Url $url * @throws \LogicException * @throws UserDoesNotHaveAnEmailException * @throws UserNotFoundException */ public function proceed(InputFilterInterface $filter, Plugin\Mailer $mailer, Url $url) { if (!$filter->isValid()) { throw new \LogicException('Form is not valid'); } $identity = $filter->getValue('identity'); $suffix = $this->loginFilter->filter(); if (!($user = $this->userRepository->findByLoginOrEmail($identity, $suffix))) { throw new UserNotFoundException('User is not found'); } if (!($email = $user->getInfo()->getEmail())) { throw new UserDoesNotHaveAnEmailException('User does not have an email'); } $tokenHash = $this->tokenGenerator->generate($user); $resetLink = $url->fromRoute('lang/goto-reset-password', array('token' => $tokenHash, 'userId' => $user->getId()), array('force_canonical' => true)); $e = new AuthEvent(); $e->setResetLink($resetLink); $e->setUser($user); $this->eventManager->trigger(AuthEvent::EVENT_AUTH_NEWPASSWORD, $e); }