예제 #1
0
 public function load(ObjectManager $manager)
 {
     // Les noms d'utilisateurs à créer
     $noms = array('winzou', 'John', 'Talus');
     $encoder = $this->container->get('security.password_encoder');
     foreach ($noms as $i => $nom) {
         // On crée l'utilisateur
         $users[$i] = new User();
         // Le nom d'utilisateur et le mot de passe sont identiques
         $users[$i]->setUsername($nom);
         $password = $encoder->encodePassword($users[$i], $nom);
         $users[$i]->setPassword($password);
         // Le sel et les rôles sont vides pour l'instant
         $users[$i]->setSalt('');
         $users[$i]->setRoles(array('ROLE_USER'));
         // On le persiste
         $manager->persist($users[$i]);
     }
     $admin = new User();
     $admin->setUsername('Kahel');
     $password = $encoder->encodePassword($admin, 'fuckpassword');
     $users[$i]->setPassword($password);
     $users[$i]->setSalt('');
     $users[$i]->setRoles(array('ROLE_ADMIN'));
     $manager->persist($admin);
     // On déclenche l'enregistrement
     $manager->flush();
 }
예제 #2
0
 public function load(ObjectManager $manager)
 {
     $encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
     $admin = new User();
     $admin->setUsername('messi');
     // On cré un salt pour amélioré la sécurité
     $admin->setPassword($encoder->encodePassword('admin', $admin->getSalt()));
     $admin->setEmail('*****@*****.**');
     $admin->setRoles(array('ROLE_ADMIN'));
     $admin->setEnabled(true);
     $user = new User();
     $user->setUsername('louis');
     // On cré un salt pour amélioré la sécurité
     $user->setPassword($encoder->encodePassword('michel', $user->getSalt()));
     $user->setEmail('*****@*****.**');
     $user->setRoles(array('ROLE_AUTEUR'));
     $user->setEnabled(true);
     $validPassword = $encoder->isPasswordValid($user->getPassword(), 'michel', $user->getSalt());
     if ($validPassword) {
         $manager->persist($admin);
         $manager->persist($user);
     }
     // On déclenche l'enregistrement
     $manager->flush();
 }
예제 #3
0
 public function load(ObjectManager $manager)
 {
     // Liste des noms de catégorie à ajouter
     $role_employe = new Role("ROLE_EMPLOYE");
     $manager->persist($role_employe);
     $manager->flush();
     $role_gestionnaire = new Role("ROLE_GESTIONNAIRE");
     $manager->persist($role_gestionnaire);
     $manager->flush();
     $role_admin = new Role("ROLE_ADMIN");
     $manager->persist($role_admin);
     $manager->flush();
     $role_superadmin = new Role("ROLE_SUPER_ADMIN");
     $manager->persist($role_superadmin);
     $manager->flush();
     $user = new User();
     $user->setNom("Njomo Rostand");
     $user->setVilleResidence("Yaounde");
     $user->setNoPieceIdent("123456789");
     $user->setPoste("Stagiare");
     $user->setUsername("rostand");
     $user->setSalt(md5(time()));
     $encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
     $password = $encoder->encodePassword('rostand', $user->getSalt());
     $user->setPassword($password);
     $user->addRole($role_employe);
     $manager->persist($user);
     $manager->flush();
     $user = new User();
     $user->setNom("Marlone NJ");
     $user->setVilleResidence("Douala");
     $user->setNoPieceIdent("9874563210");
     $user->setPoste("Gestionnaire de credit");
     $user->setUsername("marlone");
     $user->setSalt(md5(time()));
     $encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
     $password = $encoder->encodePassword('marlone', $user->getSalt());
     $user->setPassword($password);
     $user->addRole($role_gestionnaire);
     $manager->persist($user);
     $manager->flush();
     $user = new User();
     $user->setNom("Rostand  Nj");
     $user->setVilleResidence("Buea");
     $user->setNoPieceIdent("123456789");
     $user->setPoste("Dj internationnal");
     $user->setUsername("rostandnj");
     $user->setSalt(md5(time()));
     $encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
     $password = $encoder->encodePassword('rostandnj', $user->getSalt());
     $user->setPassword($password);
     $user->addRole($role_admin);
     $manager->persist($user);
     $manager->flush();
 }
예제 #4
0
 public function load(ObjectManager $manager)
 {
     $noms = array('winzoo', 'khalid', 'fatima', 'sawsane');
     foreach ($noms as $nom) {
         $user = new User();
         $user->setUsername($nom);
         $user->setSalt('');
         $user->setRoles(array());
         //on le persiste
         $manager->persist($user);
     }
     // on déclenche l'enregistrement
     $manager->flush();
 }