Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @Route("/SignUp", name="wx_exchange_signup")
- * @Template("WXExchangeBundle:User:signup.html.twig")
- * User sign up - Open to public
- * Creates new users based on information they provide
- */
- public function signupAction()
- {
- $registration = new Registration();
- $form = $this->createForm(new RegistrationType(), $registration, array(
- 'action' => $this->generateUrl('wx_exchange_signup_create'),
- ));
- return array('form' => $form->createView());
- }
- /**
- * @Route("/SignUp/create", name="wx_exchange_signup_create")
- * @Template("WXExchangeBundle:User:signup.html.twig")
- * User sign up - Open to public
- * Creates new users based on information they provide
- */
- public function signupCreateAction(Request $request)
- {
- $em = $this->getDoctrine()->getManager();
- $form = $this->createForm(new RegistrationType(), new Registration());
- $form->handleRequest($request);
- if ($form->isValid()) {
- $registration = $form->getData();
- $factory = $this->get('security.encoder_factory');
- $user = $registration->getUser();
- $user->setUserip($this->container->get('request')->getClientIp(););
- $encoder = $factory->getEncoder($user);
- $password = $encoder->encodePassword($user->getPassword(), $user->getSalt());
- $user->setPassword($password);
- $em->persist($user);
- $em->flush();
- return $this->redirect($this->generateUrl("wx_exchange_default_index"));
- }
- return array('form' => $form->createView());
- }
- /**
- * @Route("/Login", name="wx_exchange_login")
- * @Template("WXExchangeBundle:User:login.html.twig")
- * User login - Open to public
- * Authenticates users to the system
- */
- public function loginAction(Request $request)
- {
- $session = $request->getSession();
- // get the login error if there is one
- if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
- $error = $request->attributes->get(
- SecurityContext::AUTHENTICATION_ERROR
- );
- } else {
- $error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
- $session->remove(SecurityContext::AUTHENTICATION_ERROR);
- }
- return $this->render(
- 'WXExchangeBundle:User:login.html.twig',
- array(
- // last username entered by the user
- 'last_username' => $session->get(SecurityContext::LAST_USERNAME),
- 'error' => $error,
- )
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement