예제 #1
0
 public function prePersistHandler(User $user, LifecycleEventArgs $event)
 {
     /** @var TokenGeneratorInterface $tokenGenerator */
     $tokenGenerator = $this->container->get('fos_user.util.token_generator');
     /** @var Mailer $mailer */
     $mailer = $this->container->get('user.mailer');
     $user->setEnabled(true);
     $user->setConfirmed(false);
     $user->setConfirmationToken($tokenGenerator->generateToken());
     $mailer->sendConfirmationEmailMessage($user);
 }
예제 #2
0
 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $admin = new User();
     $admin->setUsername('admin');
     $admin->setEnabled(true);
     $admin->setEmail('*****@*****.**');
     $admin->setPlainPassword('admin');
     $admin->addRole('ROLE_SUPER_ADMIN');
     $em->persist($admin);
     $em->flush();
 }
예제 #3
0
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setPassword('$2y$13$Br1BVfk/wvTn.ChezqDQfOrTpYUnJqHsolRGJX04bN7bW3EFf2PUe');
     // = MDP2admin
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setEnabled(true);
     $userAdmin->setRoles(array('ROLE_AUTHENTIFICATED'));
     $manager->persist($userAdmin);
     $manager->flush();
 }
예제 #4
0
 /**
  * Creates a user.
  *
  * @param array $userData
  *
  * @return UserInterface
  */
 protected function createUser(array $userData)
 {
     $user = new User();
     $user->setUsername($userData['username']);
     $user->setEmail($userData['email']);
     $user->setPlainPassword($userData['password']);
     $user->setEnabled($userData['enabled']);
     foreach ($userData['groups'] as $group) {
         $group = $this->getReference($group);
         if ($group instanceof Group) {
             $user->addGroup($group);
         }
     }
     return $user;
 }
예제 #5
0
 /**
  * @param string $firstname
  * @param string $lastname
  * @param Group  $offshoot
  *
  * @return User
  */
 private function createUser($firstname, $lastname, $offshoot = null)
 {
     $user = new User();
     $user->setFirstname($firstname);
     $user->setLastname($lastname);
     $user->setPlainPassword($firstname);
     $user->setEmail($firstname . '@mail.com');
     $user->setEnabled(true);
     if ($offshoot) {
         $user->setProfileType(User::FORMER_MEMBER);
         $user->setOffshootOfOrigin($offshoot);
     } else {
         $user->setProfileType(User::NETWORK_VOLUNTEER);
     }
     return $user;
 }
예제 #6
0
 private function generateUsers(ObjectManager $manager)
 {
     $users = array(array('userName' => 'admin', 'firstName' => 'John', 'lastName' => 'DOE', 'email' => '*****@*****.**', 'password' => 'admin', 'roles' => array('ROLE_ADMIN'), 'enabled' => true), array('userName' => 'adacosta', 'firstName' => 'Alfonse', 'lastName' => 'DA COSTA', 'email' => '*****@*****.**', 'password' => 'adacosta', 'enabled' => true), array('userName' => 'jessy', 'firstName' => 'Jessy', 'lastName' => 'JAMES', 'email' => '*****@*****.**', 'password' => 'jessy', 'enabled' => true), array('userName' => 'alice', 'firstName' => 'Alice', 'lastName' => 'Flint', 'email' => '*****@*****.**', 'password' => 'alice', 'enabled' => false));
     foreach ($users as $key => $user) {
         $entry = new User();
         $entry->setUserName($user['userName']);
         $entry->setFirstName($user['firstName']);
         $entry->setLastName($user['lastName']);
         $entry->setEmail($user['email']);
         $entry->setPlainPassword($user['password']);
         $entry->setEnabled($user['enabled']);
         if (isset($user['roles'])) {
             foreach ($user['roles'] as $role) {
                 $entry->addRole($role);
             }
         }
         $manager->persist($entry);
     }
 }
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('Admin Test');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setPlainPassword('admin');
     $userAdmin->setEnabled(true);
     $userAdmin->setRoles(array('ROLE_ADMIN'));
     $user = new User();
     $user->setUsername('User');
     $user->setEmail('*****@*****.**');
     $user->setPlainPassword('user');
     $user->setEnabled(true);
     $user->setRoles(array('ROLE_USER'));
     $manager->persist($userAdmin);
     $manager->persist($user);
     $manager->flush();
     $this->addReference('user', $userAdmin);
 }
예제 #8
0
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('admin');
     $user->setEmail('*****@*****.**');
     $user->setPlainPassword('admin');
     $user->setEnabled(true);
     $guest = new Guest();
     $guest->setLastName('Wawrinka');
     $guest->setFirstName('Stan');
     $guest->setGender('Male');
     $event = new Event();
     $event->setName('Paléo Festival');
     $event->setDate(new \DateTime("2015-12-26"));
     $event->setPlace('Nyon');
     $event->setCapacity(230000);
     $event->addGuest($guest);
     $manager->persist($user);
     $manager->persist($guest);
     $manager->persist($event);
     $manager->flush();
 }
예제 #9
0
 public function load(ObjectManager $manager)
 {
     $groupList = $this->getGroupList();
     foreach ($groupList as $groupItem) {
         $group = new Group($groupItem["name"], $groupItem["roles"]);
         $manager->persist($group);
     }
     $manager->flush();
     $userList = $this->getUserList();
     foreach ($userList as $userItem) {
         $user = new User();
         $user->setUsername($userItem["username"]);
         $user->setEmail($userItem["email"]);
         $user->setEnabled($userItem["enabled"]);
         $encoder = $this->container->get('security.password_encoder');
         $password = $encoder->encodePassword($user, $userItem["username"], $user->getSalt());
         $user->setPassword($password);
         $group = $this->container->get("fos_user.group_manager")->findGroupByName($userItem["group"]);
         $user->addGroup($group);
         $manager->persist($user);
     }
     $manager->flush();
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var EntityManager $em */
     $em = $this->getContainer()->get('doctrine')->getManager();
     $docuser = new User();
     $docuser->setEnabled(1);
     $docuser->setFirstname("Doc");
     $docuser->setLastname("User");
     $docuser->setEmail("*****@*****.**");
     $docuser->setUsername("doc");
     $docuser->setPlainPassword($this->generateRandomString());
     $docuser->setEmailgalaxy("*****@*****.**");
     $em->persist($docuser);
     $apiuser = new User();
     $apiuser->setEnabled(1);
     $apiuser->setFirstname("api");
     $apiuser->setLastname("User");
     $apiuser->setEmail("*****@*****.**");
     $apiuser->setUsername("api");
     $apiuser->setPlainPassword($this->generateRandomString());
     $apiuser->setEmailgalaxy("*****@*****.**");
     $em->persist($apiuser);
     $em->flush();
 }
 /**
  * {@inheritDoc}
  */
 public function setEnabled($boolean)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setEnabled', [$boolean]);
     return parent::setEnabled($boolean);
 }
예제 #12
0
 /**
  * @param User $object User
  */
 public function prePersist($object)
 {
     $object->setEnabled(true);
     $object->setRoles(array('ROLE_ADMIN'));
 }
     } else {
         $view->setData('User don\'t delete')->setStatusCode(404);
     }
     return $view;
 }
 /**
  * Return an user identified by login/password.
  * @Get("/users/check_session/username={username}&password={password}")
  * @param $username
  * @param $password
  * @return View
  */
 public function checkSessionAction($username, $password)
 {
     $em = $this->getDoctrine()->getManager();
     $user = $em->getRepository('UserBundle:User')->findOneByUsername($username);
     if ($user) {
         $encoder = $this->container->get('security.encoder_factory')->getEncoder($user);
         if ($encoder->encodePassword($password, $user->getSalt()) === $user->getPassword()) {
             return $user;
         }
     }
     return array();
 }
예제 #14
0
 /**
  * Add a User
  *
  * @author Jeremie Samson <*****@*****.**>
  *
  * @param ModelUser $user
  */
 protected function onSuccess(ModelUser $model, Section $section)
 {
     $user = new User();
     $user->setEnabled(true);
     $user->setRandomPassword();
     $user->setFirstname($model->getFirstname());
     $user->setLastname($model->getLastname());
     $user->setEmailgalaxy($model->getEmailGalaxy());
     $user->setEmail($model->getEmail() ? $model->getEmail() : $model->getEmailGalaxy());
     $user->setUsername($model->getEmailgalaxy());
     $user->setMobile($model->getMobile());
     $section->addUser($user);
     $this->em->persist($user);
     $this->em->flush();
 }