Beispiel #1
0
 /**
  * @Route("/login", name="account_login")
  * @Method("GET")
  */
 public function loginAction()
 {
     $securityContext = $this->container->get('security.context');
     if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         return new RedirectResponse($this->container->get('router')->generate('account_index'));
     }
     $request = $this->container->get('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);
     }
     if (in_array($this->get('kernel')->getEnvironment(), array('mobile', 'mobile_dev'))) {
         $customer = new AccountData();
         $customer->setLocale($this->getRequest()->getLocale());
         $newAccountData = new NewAccountData();
         $newAccountData->setCustomer($customer);
         $newAccountForm = $this->container->get('form.factory')->create(new NewAccountType(), $newAccountData);
         return $this->render('MobileBundle::login.html.twig', array('last_username' => $session->get(SecurityContext::LAST_USERNAME), 'error' => $error, 'newAccountForm' => $newAccountForm->createView()));
     }
     return $this->render('SehBundle::login.html.twig', array('last_username' => $session->get(SecurityContext::LAST_USERNAME), 'error' => $error));
 }
Beispiel #2
0
 /**
  * @Route("/account/create", name="account_create_process")
  * @Method("POST")
  */
 public function createProcessAction(Request $request)
 {
     $form = $this->createForm(new NewAccountType(), $newAccountData = new NewAccountData());
     $form->submit($request);
     if ($form->isValid()) {
         if ($this->getRequest()->isXmlHttpRequest()) {
             return new JsonResponse(array('success' => true));
         }
         $accountData = $newAccountData->getCustomer();
         /** @var EntityManager $em */
         $em = $this->container->get('doctrine')->getManager();
         $title = $em->getRepository('SehBundle:Customer\\Title')->find($accountData->getTitle());
         $customer = new Customer();
         $customer->setTitle($title);
         $customer->setGalittTitle($title->getGalittTitle()->getValue());
         $accountData->toUser($customer);
         $customer->setLoyalty($newAccountData->getLoyalty());
         $customer->setActive(false);
         $customer->setToken(hash('sha512', $customer->getLastName() . ' ' . $customer->getFirstName() . ' ' . $customer->getEmail()));
         if ($newAccountData->getAccentCard()) {
             $customer->setTempCardNumber($newAccountData->getAccentCard());
         }
         $em->persist($customer);
         try {
             /** @var Translator $translator */
             $translator = $this->get('translator');
             $subject = $translator->trans('receipt.email.account.create.subject');
             $mailParams = $this->container->getParameter('emails');
             $body = $this->renderView('SehBundle:mails:account_validation.html.twig', array('title' => $customer->getTitle(), 'fullName' => ucfirst($customer->getLastName()) . ' ' . ucfirst($customer->getFirstName()), 'token' => $customer->getToken(), 'subject' => $subject));
             $mailNewAccount = \Swift_Message::newInstance()->setContentType('text/html')->setFrom(array($mailParams['booking']['sender_mail'] => $mailParams['booking']['sender_name']))->addTo($customer->getEmail())->setSubject($subject)->setBody($body);
             $this->get('mailer')->send($mailNewAccount);
             $this->container->get('session')->getFlashBag()->add('success', 'form.create_account.email.sent.account.to.activate');
             // Checking Token Facebook
             $this->get('seh.facebook_manager')->setFacebookSessionByCustomer($customer);
             $em->flush();
         } catch (\Exception $e) {
             $this->container->get('logger')->error($e->getMessage());
         }
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new JsonResponse(array('success' => false, 'errors' => $this->getFormErrorsAsArray($form)));
     }
     if (in_array($this->get('kernel')->getEnvironment(), array('mobile', 'mobile_dev'))) {
         return new RedirectResponse($this->generateUrl('account_login'));
     } else {
         return new RedirectResponse($this->generateUrl('account_create'));
     }
 }
Beispiel #3
0
 /**
  * @Route("/identification/new_account/process", name="booking_step_three_new_account_process", schemes={"https"})
  * @Method("POST")
  */
 public function processNewAccountForm(Request $request)
 {
     $newAccountForm = $this->createForm(new NewAccountType(), $newAccountData = new NewAccountData());
     $newAccountForm->submit($request);
     if ($request->hasSession('facebook.session')) {
         $facebookSession = $request->getSession()->get('facebook.session');
         $newAccountData->getCustomer()->setFacebookToken(sha1($facebookSession['id'] . 'sehc2is'));
     }
     $bookingManager = $this->getBookingManager();
     $bookingUserSelection = $this->getCurrentBooking();
     if ($bookingUserSelection->getProcessed()) {
         return new JsonResponse(array('success' => true));
     }
     $bookingUserSelection->setNewAccountData($newAccountData);
     $bookingManager->saveBookingToSession($bookingUserSelection);
     if ($newAccountForm->isValid()) {
         if ($request->isXmlHttpRequest()) {
             return new JsonResponse(array('success' => true));
         }
     }
     if ($request->isXmlHttpRequest()) {
         return new JsonResponse(array('success' => false));
     }
     $bookingUserSelection->validateStep(3);
     $bookingManager->saveBookingToSession($bookingUserSelection);
     return new RedirectResponse($this->generateUrl('booking_step_four', array('bookingId' => $bookingUserSelection->getBookingId())));
 }