Exemplo n.º 1
0
 /**
  * newFrontendUser
  *
  * @param string $username
  * @param string $password
  * @return FrontendUser $frontendUser
  */
 public function newFrontendUser($username, $password)
 {
     $user = new FrontendUser();
     $user->setUsername($username);
     $user->setEmail($this->faker->email);
     $user->setPlainPassword($password);
     $this->em->persist($user);
     $this->em->flush();
     return $user;
 }
Exemplo n.º 2
0
 public function testUserPasswordListener()
 {
     $user = new FrontendUser();
     $user->setUsername($this->faker->userName);
     $user->setEmail($this->faker->email);
     $user->setPlainPassword($this->faker->password());
     $this->em->persist($user);
     $this->em->flush();
     $this->assertNotEmpty($user->getId());
     $this->removeEntity($user);
 }
Exemplo n.º 3
0
 /**
  * Creates user, specially for fixtures
  *
  * @param array $userData
  *
  * @return FrontendUser $user
  */
 public function registerFixturesUser(array $userData)
 {
     $user = new FrontendUser();
     $user->setEmail($userData['email']);
     $user->setUsername($userData['username']);
     $user->setPlainPassword($userData['password']);
     $user->setEnabled($userData['enabled']);
     $user->setLocked($userData['locked']);
     $user->setLastLogin(new \DateTime(date('Y-m-d H:i:s')));
     $user->setPhone($userData['phone']);
     $user->setWebsite($userData['website']);
     $user->setFacebook($userData['facebook']);
     $user->setTwitter($userData['twitter']);
     $user->setAbout($userData['about']);
     $this->em->persist($user);
     $this->em->flush();
     return $user;
 }
Exemplo n.º 4
0
 /**
  *   Reset and send password by email
  */
 public function resetPassword(FrontendUser $user)
 {
     if ($user) {
         $utility = new PasswordUtility();
         $password = $utility->generatePassword();
         $user->setPlainPassword($password);
         $this->dm->persist($user);
         $this->dm->flush();
         // Send password via email
         try {
             $message = \Swift_Message::newInstance()->setSubject('Password reset')->setFrom($this->websiteEmail)->setTo($user->getEmail())->setBody($this->templating->render('AiselFrontendUserBundle:Email:newPassword.txt.twig', array('username' => $user->getUsername(), 'password' => $password)));
             $response = $this->mailer->send($message);
         } catch (\Swift_TransportException $e) {
             $response = $e->getMessage();
         }
         return $response;
     } else {
         return false;
     }
 }