public function create(FormInterface $form, Request $request) { $form->handleRequest($request); if (!$form->isValid()) { return false; } $entity = $form->getData(); if ($form->isSubmitted()) { if (!is_null($this->manager->checkUniqueEmail($entity->getUser()->getEmail()))) { $form->addError(new FormError('Email ja cadastrado!')); return false; } } $this->manager->create($entity); return true; }
/** * Return a UserInterface object based on the credentials. * * The *credentials* are the return value from getCredentials() * * You may throw an AuthenticationException if you wish. If you return * null, then a UsernameNotFoundException is thrown for you. * * @param mixed $credentials * @param UserProviderInterface $userProvider * * @throws AuthenticationException * * @return UserInterface|null */ public function getUser($credentials, UserProviderInterface $userProvider) { $email = $credentials['email']; $user = $this->gestorUserManager->findUserByEmail($email); if (is_null($user)) { throw CustomAuthenticationException::createWithSafeMessage('security.login.errors.email_not_found'); } return $user; }