findUserByEmail() public method

Finds a user by email
public findUserByEmail ( string $email ) : User
$email string
return User
 private function testIfEmailAlreadyInUse()
 {
     $email = $this->userManager->findUserByEmail($this->submitDatas['email']);
     if ($email) {
         throw new \Exception(json_encode(array("email" => "Cet email est déjà utilisé.")), 403);
     }
 }
Esempio n. 2
0
 /**
  * Fonction permettant de savoir si un utilisateur existe déja selon son username et email
  * @since 2.3 fourth argument id has ben removed
  * @param UserManager $userManager
  * @param string $username
  * @param string $userMail
  */
 private function userAlreadyExist(UserManager $userManager, $username, $userMail)
 {
     $alreadyExist = false;
     $userByUsername = $userManager->findUserByUsername($username);
     $userByUserMail = $userManager->findUserByEmail($userMail);
     if (isset($userByUsername)) {
         $this->get('session')->getFlashBag()->add('notice', "Le nom d'utilisateur est déjà utilisé.");
         $alreadyExist = true;
     }
     if (isset($userByUserMail)) {
         $this->get('session')->getFlashBag()->add('notice', "L'adresse e-mail est déjà utilisée.");
         $alreadyExist = true;
     }
     return $alreadyExist;
 }