public function handle(FormInterface $form, Request $request) { $form->handleRequest($request); if (!$form->isValid()) { return false; } $data = $form->getData(); if ($form->isSubmitted()) { $user = $this->userManager->findUserByEmail($data['email']); if (is_null($user)) { $form->addError(new FormError($this->translator->trans('security.resetting.request.errors.email_not_found'))); return false; } if ($user->isPasswordRequestNonExpired($this->tokenTll)) { $form->addError(new FormError($this->translator->trans('security.resetting.request.errors.password_already_requested'))); return false; } if ($user->getConfirmationToken() === null) { $user->setConfirmationToken($this->tokenGenerator->generateToken()); } $user->setPasswordRequestedAt(new \DateTime()); $this->userManager->resettingRequest($user); } return true; }
public function onInteractiveLogin(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); if ($user instanceof User) { $user->setLastLoginAt(new \DateTime()); $this->userManager->editLastLogin($user); } }
public function handle(FormInterface $form, Request $request) { $form->handleRequest($request); if (!$form->isValid()) { return false; } $entity = $form->getData(); $this->userManager->resettingReset($entity); $this->flashBag->add(FlashBagEvents::MESSAGE_TYPE_SUCCESS, $this->translator->trans('security.resetting.reset.success')); return true; }