Пример #1
0
 /**
  * @Route("/register", name="user_register")
  * @Template("UserBundle:Security:register.html.twig")
  *
  * @var Request $request
  * @return array
  */
 public function registerAction(Request $request)
 {
     $user = new User();
     $user->setUsername('Your_user_name');
     $form = $this->createForm(new RegisterFormType(), $user);
     if ($this->handleFormRequest($form, $request) === true) {
         return $this->redirect($this->generateUrl('login_form'));
     }
     return array('form' => $form->createView());
 }
Пример #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('remus');
     $user->setEmail('*****@*****.**');
     $user->setPassword($this->encodePassword($user, 'remuspass'));
     $manager->persist($user);
     $admin = new User();
     $admin->setUsername('cicu');
     $admin->setEmail('*****@*****.**');
     $admin->setPassword($this->encodePassword($admin, 'cicupass'));
     $admin->setRoles(array('ROLE_ADMIN'));
     $manager->persist($admin);
     // the queries aren't done until now
     $manager->flush();
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('darth');
     $user->setPassword($this->encodePassword($user, 'darthpass'));
     $user->setEmail('*****@*****.**');
     // $user->setIsActive(true);
     $manager->persist($user);
     $admin = new User();
     $admin->setUsername('wayne');
     $admin->setPassword($this->encodePassword($admin, 'waynepass'));
     $admin->setRoles(array('ROLE_ADMIN'));
     $admin->setEmail('*****@*****.**');
     // $admin->setIsActive(false);
     $manager->persist($admin);
     $manager->flush();
 }
Пример #4
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('user');
     $user->setPlainPassword('user');
     $user->setEmail('*****@*****.**');
     $manager->persist($user);
     $this->addReference('user-user', $user);
     $admin = new User();
     $admin->setUsername('admin');
     $admin->setPlainPassword('admin');
     $admin->setRoles(array('ROLE_ADMIN'));
     $admin->setEmail('*****@*****.**');
     $manager->persist($admin);
     // the queries aren't done until now
     $manager->flush();
 }
Пример #5
0
 public function load($manager)
 {
     $user = new User();
     $user->setUsername('user');
     $user->setPlainPassword('user');
     $user->setEmail('*****@*****.**');
     $manager->persist($user);
     // pass to other fixtures
     $this->addReference('user-user', $user);
     $admin = new User();
     $admin->setUsername('admin');
     $admin->setPlainPassword('admin');
     $admin->setRoles(array('ROLE_ADMIN'));
     $admin->setEmail('*****@*****.**');
     $manager->persist($admin);
     $manager->flush();
 }
 /**
  * @Route("/register", name="user_register")
  * @Template()
  */
 public function registerAction(Request $request)
 {
     $user = new User();
     $user->setUsername('Leia');
     $form = $this->createForm(new RegisterFormType(), $user);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $user = $form->getData();
         $user->setPassword($this->encodePassword($user, $user->getPlainPassword()));
         $em = $this->getDoctrine()->getManager();
         $em->persist($user);
         $em->flush();
         $this->authenticateUser($user);
         $request->getSession()->getFlashbag()->add('success', 'Welcome to the Death Star! Have a magical day!');
         $url = $this->generateUrl('event');
         return $this->redirect($url);
     }
     return array('form' => $form->createView());
 }
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('darth');
     //$user->setPassword($this->encodePassword($user, 'darthpass'));
     $user->setRoles(array('ROLE_USER'));
     $user->setPlainPassword('darthpass');
     $user->setEmail('*****@*****.**');
     $manager->persist($user);
     $admin = new User();
     $admin->setUsername('wayne');
     //$admin->setPassword($this->encodePassword($admin, 'waynepass'));
     $admin->setRoles(array('ROLE_ADMIN'));
     $admin->setEmail('*****@*****.**');
     $admin->setPlainPassword('waynepass');
     $manager->persist($admin);
     // the queries aren't done until now
     $manager->flush();
 }
Пример #8
0
 /**
  * @Route("/register", name="user_register")
  * @Template
  */
 public function registerAction(Request $request)
 {
     $defaultUser = new User();
     $defaultUser->setUsername('Foo');
     $form = $this->createForm(new RegisterFormType(), $defaultUser);
     if ($request->isMethod('POST')) {
         $form->bind($request);
         if ($form->isValid()) {
             $user = $form->getData();
             $em = $this->getDoctrine()->getManager();
             $em->persist($user);
             $em->flush();
             $request->getSession()->getFlashBag()->add('success', 'Registration went super smooth!');
             $this->authenticateUser($user);
             $url = $this->generateUrl('event');
             return $this->redirect($url);
         }
     }
     return array('form' => $form->createView());
 }
Пример #9
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $utils = new UserUtils($this->container);
     $user = new User();
     $user->setUsername('darth');
     $user->setPassword($utils->encodePassword($user, 'pass'));
     $user->setIsActive(false);
     $manager->persist($user);
     $user1 = new User();
     $user1->setUsername('vikbert');
     $user1->setPassword($utils->encodePassword($user1, 'pass'));
     $user1->setIsActive(true);
     $user1->setEmail('*****@*****.**');
     $manager->persist($user1);
     $user2 = new User();
     $user2->setUsername('demo');
     $user2->setPassword($utils->encodePassword($user2, 'pass'));
     $user2->setIsActive(false);
     $manager->persist($user2);
     $manager->flush();
 }
Пример #10
0
 /**
  * @Route("/register", name="user_register")
  * @Template
  */
 public function registerAction(Request $request)
 {
     $defaultUser = new User();
     $defaultUser->setUsername('foo');
     $form = $this->createForm(new RegisterFormType(), $defaultUser);
     if ('POST' == $request->getMethod()) {
         $form->bindRequest($request);
         if ($form->isValid()) {
             $user = $form->getData();
             $user->setPassword($this->encodePassword($user, $user->getPlainPassword()));
             $em = $this->getDoctrine()->getEntityManager();
             $em->persist($user);
             $em->flush();
             $request->getSession()->setFlash('success', 'Registration went super well!');
             $url = $this->generateUrl('event');
             // authenticate user
             $this->authenticateUser($user);
             return $this->redirect($url);
         }
     }
     return array('form' => $form->createView());
 }
 /**
  * @Route("/register",name="user_register")
  * @Template()
  */
 public function registerAction(Request $request)
 {
     $defaultUser = new User();
     $defaultUser->setUsername('Foo');
     $form = $this->createForm(new RegisterFormType(), $defaultUser);
     $form->handleRequest($request);
     $data = $form->getData();
     if ($form->isSubmitted() && $form->isValid()) {
         $data = $form->getData();
         $user = new User();
         $user->setUsername($data->getUsername());
         $user->setEmail($data->getEmail());
         $user->setPassword($this->encodePassword($user, $data->getPlainPassword()));
         $user->setPlainPassword(NULL);
         $user->setRoles(array('ROLE_USER'));
         $em = $this->getDoctrine()->getManager();
         $em->persist($user);
         $em->flush();
         $this->authenticateUser($user);
         $url = $this->generateUrl('event');
         return $this->redirect($url);
     }
     return array('form' => $form->createView());
 }