/**
  * {@inheritdoc}
  */
 protected function getSessionToken()
 {
     if (!$this->session->has($this->name)) {
         $this->session->set($this->name, sha1(uniqid(rand(), true)));
     }
     return $this->session->get($this->name);
 }
Ejemplo n.º 2
0
 /**
  * @param $name
  * @return Filter
  */
 public function get($name, $reset = false)
 {
     if (!$this->session->has('filter_' . $name) || $reset) {
         $this->session->set('filter_' . $name, new Filter());
     }
     return $this->session->get('filter_' . $name);
 }
Ejemplo n.º 3
0
 /**
  *
  * @return array
  */
 public function getChoices()
 {
     if ($this->sessionManager->has('choices')) {
         return $this->sessionManager->get('choices');
     }
     return [];
 }
Ejemplo n.º 4
0
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($this->session->has('_locale')) {
         $event->getRequest()->setLocale($this->session->get('_locale'));
         $this->translator->setLocale($this->session->get('_locale'));
     }
 }
Ejemplo n.º 5
0
 public function __construct(Registry $doctrine, Session $session, Logger $logger, Parameters $parameters)
 {
     $this->doctrine = $doctrine;
     $this->session = $session;
     $this->logger = $logger;
     $this->parameters = $parameters;
     $this->emFrom = $this->doctrine->getManager($this->parameters->getManagerFrom());
     $this->emTo = $this->doctrine->getManager($this->parameters->getManagerTo());
     $fromRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $fromRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     //$toRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerTo() );
     //$toRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $this->fromAnalyzer = new PgAnalyzer($this->logger, $fromRetriever);
     //$this->toAnalyzer = new PgAnalyzer($this->logger, $toRetriever);
     if ($this->session->has(CompareStructure::SESSION_FROM_KEY)) {
         $this->fromAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_FROM_KEY));
         $this->fromAnalyzer->initTables();
     } else {
         throw new SyncException('No source data');
     }
     /*if($this->session->has(CompareStructure::SESSION_TO_KEY)){
           $this->toAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_TO_KEY));
           $this->toAnalyzer->initTables();
       }else{
           throw new SyncException('No targeted data');
       }*/
 }
Ejemplo n.º 6
0
 /**
  * @param Registry $doctrine
  * @param Session $session
  * @param Logger $logger
  * @param Parameters $parameters
  */
 public function __construct(Registry $doctrine, Session $session, Logger $logger, Parameters $parameters)
 {
     $this->doctrine = $doctrine;
     $this->session = $session;
     $this->logger = $logger;
     $this->parameters = $parameters;
     $fromRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $fromRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $fromMassRetriever = new PgMassRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $toRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerTo());
     $toRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $toMassRetriever = new PgMassRetriever($doctrine, $this->logger, $this->parameters->getManagerTo());
     $this->fromAnalyzer = new PgAnalyzer($this->logger, $fromRetriever, $fromMassRetriever);
     $this->toAnalyzer = new PgAnalyzer($this->logger, $toRetriever, $toMassRetriever);
     if ($this->session->has(SyncHandler::SESSION_FROM_KEY)) {
         $this->fromAnalyzer->setSchemas($this->session->get(SyncHandler::SESSION_FROM_KEY));
         $this->fromAnalyzer->initTables();
     } else {
         $this->fromAnalyzer->initSchemas();
         $this->fromAnalyzer->initSchemasElements();
         $this->fromAnalyzer->initCompareTableInfo();
         //$this->session->set(SyncHandler::SESSION_FROM_KEY, $this->fromAnalyzer->getSchemas());
     }
     if ($this->session->has(SyncHandler::SESSION_TO_KEY)) {
         $this->toAnalyzer->setSchemas($this->session->get(SyncHandler::SESSION_TO_KEY));
         $this->toAnalyzer->initTables();
     } else {
         $this->toAnalyzer->initSchemas();
         $this->toAnalyzer->initSchemasElements();
         $this->toAnalyzer->initCompareTableInfo();
         $this->toAnalyzer->initTables();
         //$this->session->set(SyncHandler::SESSION_TO_KEY, $this->toAnalyzer->getSchemas());
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         // don't do anything if it's not the master request
         return;
     }
     $token = $this->context->getToken();
     if (is_null($token)) {
         return;
     }
     $_route = $event->getRequest()->attributes->get('_route');
     if ($this->context->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         if (!$token->getUser() instanceof PersonInterface) {
             // We don't have a PersonInterface... Nothing to do here.
             return;
         }
         if ($_route == 'lc_home' || $_route == 'fos_user_security_login') {
             $key = '_security.main.target_path';
             #where "main" is your firewall name
             //check if the referer session key has been set
             if ($this->session->has($key)) {
                 //set the url based on the link they were trying to access before being authenticated
                 $url = $this->session->get($key);
                 //remove the session key
                 $this->session->remove($key);
             } else {
                 $url = $this->router->generate('lc_dashboard');
             }
             $event->setResponse(new RedirectResponse($url));
         } else {
             $this->checkUnconfirmedEmail();
         }
     }
 }
Ejemplo n.º 8
0
 public function getCurrentSite(Request $request)
 {
     $currentSite = null;
     $siteId = $request->get('site');
     if (!$siteId && $this->session->has(self::SESSION_NAME)) {
         $currentSiteId = $this->session->get(self::SESSION_NAME);
         $currentSite = $this->siteManager->find($currentSiteId);
         if (!$currentSite) {
             $sites = $this->getSites();
             if (count($sites) > 0) {
                 $currentSite = $this->getSites()[0];
             }
         }
     } else {
         foreach ($this->getSites() as $site) {
             if ($siteId && $site->getId() == $siteId) {
                 $currentSite = $site;
             } elseif (!$siteId && $site->getIsDefault()) {
                 $currentSite = $site;
             }
         }
         if (!$currentSite && count($this->sites) > 0) {
             $currentSite = $this->sites[0];
         }
     }
     if ($currentSite) {
         $this->session->set(self::SESSION_NAME, $currentSite->getId());
     }
     return $currentSite;
 }
Ejemplo n.º 9
0
 /**
  * Start engine with given players or from session if players is not defined
  * @param Session $session
  * @param PlayerInterface $player1
  * @param PlayerInterface $player2
  * @param Board $board
  * @return EngineInterface|GameEngine|mixed
  * @throws \InvalidArgumentException if no players is defined in both arguments and session
  */
 public static function start(Session $session, PlayerInterface $player1 = null, PlayerInterface $player2 = null, Board $board = null)
 {
     if ((!$player1 || !$player2) && (!$session->has('player1') || !$session->has('player2'))) {
         throw new \InvalidArgumentException('You must specify players to start the engine');
     }
     //restart the game
     if ($player1 && $player2) {
         $session->set('player1', $player1);
         $session->set('player2', $player2);
         $board = new Board(array());
         $session->set('board', $board);
         self::$gameEngine = new GameEngine($session, $player1, $player2, $board);
         return self::$gameEngine;
     }
     if (self::$gameEngine) {
         return self::$gameEngine;
     }
     if (!$player1 || !$player2 && ($session->has('player1') && $session->has('player2'))) {
         $player1 = $session->get('player1');
         $player2 = $session->get('player2');
         $board = $session->get('board');
         $player1->setBoard($board);
         $player2->setBoard($board);
     }
     if (!$board) {
         $board = new Board(array());
     }
     self::$gameEngine = new GameEngine($session, $player1, $player2, $board);
     return self::$gameEngine;
 }
Ejemplo n.º 10
0
 public function testCanUnsetAVariable()
 {
     $this->session->set('testUnset', 5);
     $this->assertEquals(5, $this->access->get('testUnset'));
     $this->access->remove('testUnset');
     $this->assertFalse($this->session->has('testUnset'));
     $this->assertFalse($this->access->has('testUnset'));
 }
Ejemplo n.º 11
0
 /**
  * Checks if the user is authenticated.
  *
  * @return bool True if the user is authenticated
  */
 public function isAuthenticated()
 {
     if (!$this->session->has('_auth_until') || $this->session->get('_auth_until') < time()) {
         return false;
     }
     // Update the expiration date
     $this->session->set('_auth_until', time() + $this->timeout);
     return true;
 }
Ejemplo n.º 12
0
 /**
  * Try to get Session or Cookies identification data
  *
  * @return array
  */
 private function getAuthData()
 {
     if ($this->session->has($this->facade->domain)) {
         return unserialize($this->session->get($this->facade->domain));
     } elseif ($this->request->cookies->has($this->facade->domain)) {
         return $this->getCookie();
     }
     return [];
 }
Ejemplo n.º 13
0
 /**
  * @param Request $request
  *
  * @return bool
  * @throws \Exception
  */
 public function validate($request)
 {
     $token = $request->request->get(self::SECURITY_TOKEN_NAME);
     if (!empty($token) && $this->session->has(self::SECURITY_TOKEN_NAME) && $this->session->get(self::SECURITY_TOKEN_NAME) == $token) {
         return true;
     }
     $sessionToken = $this->session->get(self::SECURITY_TOKEN_NAME);
     throw new \Exception(sprintf('Token is invalid or empty. Expects <<%s>> but gotten <<%s>>', $sessionToken, $token));
 }
Ejemplo n.º 14
0
 public function pullMessages($parentRoute = null)
 {
     if ($this->session->has(Messages::$_MESSAGES_POOL_NAME)) {
         $poolOfMessages = $this->session->get(Messages::$_MESSAGES_POOL_NAME);
         $this->session->remove(Messages::$_MESSAGES_POOL_NAME);
     } else {
         $poolOfMessages = null;
     }
     return $poolOfMessages;
 }
Ejemplo n.º 15
0
 /**
  * Loads input from the session, which has been persisted through the response class
  *
  * @return void
  * @author Dan Cox
  */
 public function oldInput()
 {
     if ($this->session->has('input\\old')) {
         $input = $this->session->get('input\\old');
         $type = $this->session->get('input\\old.type');
         $deobsfucated = unserialize(base64_decode($input));
         $this->putInput($deobsfucated, $type);
         $this->session->remove('input\\old');
         $this->session->remove('input\\old.type');
     }
 }
 /**
  * Get a persisted pass value
  *
  * @return bool
  */
 protected function getStickyRatioPass()
 {
     $sessionKey = '_ecn_featuretoggle_' . $this->feature;
     if ($this->session->has($sessionKey)) {
         $pass = $this->session->get($sessionKey);
     } else {
         $pass = $this->getRatioPass();
         $this->session->set($sessionKey, $pass);
     }
     return $pass;
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('email', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType', array('required' => true, 'label' => 'form.email', 'attr' => array('placeholder' => 'form.email.example'), 'translation_domain' => 'FOSUserBundle'))->add('plainPassword', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType', array('required' => true, 'type' => 'Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType', 'attr' => array('autocomplete' => 'off', 'placeholder' => 'form.plainPassword.example'), 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.password', 'attr' => array('placeholder' => 'form.plainPassword.example')), 'second_options' => array('label' => 'form.password_confirmation', 'attr' => array('placeholder' => 'form.plainPassword.confirm.example')), 'invalid_message' => 'fos_user.password.mismatch'));
     if ($this->session->has('requested_scope')) {
         $builder->add('firstName', null, ['required' => true, 'label' => 'person.form.firstName.label', 'attr' => ['placeholder' => 'person.form.firstName.placeholder']]);
         $requestedScope = explode(' ', $this->session->get('requested_scope'));
         foreach ($requestedScope as $scope) {
             $this->addDynamicField($builder, $scope);
         }
     }
 }
Ejemplo n.º 18
0
 protected function loadCart()
 {
     if (!$this->session->has('cart')) {
         $this->session->set('cart', ['total' => 0, 'items' => []]);
     }
     $cart = $this->session->get('cart');
     if (!isset($cart['total'], $cart['items'])) {
         $this->session->set('cart', ['total' => 0, 'items' => []]);
         $cart = $this->session->get('cart');
     }
     return $cart;
 }
Ejemplo n.º 19
0
 /**
  * Automatic detection of language
  *
  * @return string
  */
 protected function getCurrentLocale()
 {
     if (!Config::$lngSwitch) {
         return Config::$lng;
     }
     if ($this->session->has('lng')) {
         return $this->session->get('lng');
     }
     $locale = $this->getUserLocale();
     $this->session->set('lng', $locale);
     return $locale;
 }
Ejemplo n.º 20
0
 public function __construct(\Eccube\Application $app)
 {
     $this->app = $app;
     $this->session = $app['session'];
     $this->entityManager = $app['orm.em'];
     if ($this->session->has('cart')) {
         $this->cart = $this->session->get('cart');
     } else {
         $this->cart = new \Eccube\Entity\Cart();
     }
     $this->loadProductClassFromCart();
     $this->BaseInfo = $app['eccube.repository.base_info']->get();
 }
Ejemplo n.º 21
0
 public function __construct(Session $session, EntityManager $entityManager)
 {
     $this->session = $session;
     $this->entityManager = $entityManager;
     if ($this->session->has('cart')) {
         $this->cart = $this->session->get('cart');
     } else {
         $this->cart = new \Eccube\Entity\Cart();
     }
     foreach ($this->cart->getCartItems() as $CartItem) {
         $ProductClass = $this->entityManager->getRepository($CartItem->getClassName())->find($CartItem->getClassId());
         $this->setCanAddProductType($ProductClass->getProductType());
     }
 }
Ejemplo n.º 22
0
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     // Session is used for save authorizations and menu is already in session
     if ($this->useSession && $this->session->has(self::KEY)) {
         return;
     }
     $authorizations = $this->getter->get();
     $items = $this->builderMenuItems->build($authorizations);
     $menu = $this->builderMenu->build($items, $event->getRequest()->getRequestUri());
     $this->session->set(self::KEY, $menu);
 }
Ejemplo n.º 23
0
 /**
  * @param string $username The username
  *
  * @return UserInterface
  *
  * @see UsernameNotFoundException
  *
  * @throws UsernameNotFoundException if the user is not found
  *
  */
 public function loadUserByUsername($username)
 {
     $sessionKey = 'seiffert_crowd_auth.user';
     if ($this->session->has($sessionKey)) {
         return $this->session->get($sessionKey);
     }
     try {
         $user = User::fromUser($this->crowd->getUser($username));
         $this->session->set($sessionKey, $user);
         return $user;
     } catch (UserNotFoundException $e) {
         throw new UsernameNotFoundException($e->getMessage(), $e->getCode(), $e);
     }
 }
 /**
  * @param \VersionControl\GitControlBundle\Entity\Project $project
  *
  * @return \VersionControl\GitControlBundle\Entity\ProjectEnvironment
  *
  * @throws \Exception
  */
 public function getProjectEnviromment(Project $project)
 {
     if ($this->session->has('projectEnvironment' . $project->getId())) {
         $projectEnvironmentId = $this->session->get('projectEnvironment' . $project->getId());
         $currentProjectEnvironment = $this->em->getRepository('VersionControlGitControlBundle:ProjectEnvironment')->find($projectEnvironmentId);
         if ($currentProjectEnvironment->getProject()->getId() === $project->getId()) {
             return $currentProjectEnvironment;
         } else {
             throw new \Exception('Project Id does not match current project');
         }
     } else {
         $currentProjectEnvironment = $project->getProjectEnvironment()->first();
     }
     return $currentProjectEnvironment;
 }
Ejemplo n.º 25
0
 public function getUserDataHeader(Session $session)
 {
     if (!$session->has('userId')) {
         return null;
     }
     return ['name' => $session->get('userName'), 'secondName' => $session->get('userSName'), 'role' => $session->get('userRole')];
 }
Ejemplo n.º 26
0
 /**
  * @param Registry $doctrine
  */
 public function initAnalysis(Registry $doctrine)
 {
     $this->compareStructure = new CompareStructure($doctrine, $this->session, $this->logger, $this->parameters);
     if ($this->session->has(self::SESSION_FROM_KEY)) {
         $this->pgSynchronizer = new PgSynchronizer($doctrine, $this->session, $this->logger, $this->parameters);
     }
 }
Ejemplo n.º 27
0
 /**
  * Tells if the storage is empty
  *
  * @return boolean
  */
 public function isEmpty()
 {
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
     return !$this->session->has(self::SESSION_STO_KEY . '-' . $this->namespace);
 }
Ejemplo n.º 28
0
 public function indexAction()
 {
     $login_session = $this->getRequest()->getSession();
     if (!$login_session) {
         $login_session = new Session();
     }
     $this->setConfig();
     // Is the user already logged in? Redirect user to the private page
     if ($login_session->has('username')) {
         // if logged in redirect to users page
         return $this->redirect($this->generateUrl('user_page'));
         //all Symfony versions
         // return $this->redirectToRoute('user_page'); // Symfony 2.6 and above
     }
     if ($this->getRequest()->request->has('submit')) {
         $login_success = $this->doLogin();
         if ($login_success) {
             return $this->redirect($this->generateUrl('user_page'));
             //all Symfony versions
         } else {
             $login_error = "The submitted login info is incorrect or you're not a Tux Coffee Corner user.";
         }
     }
     //render login-form
     return $this->render('TuxCoffeeCornerUserBundle::userLogin.html.php', array('login_error' => $login_error));
 }
Ejemplo n.º 29
0
 public function indexAction(Request $request)
 {
     $session = new Session();
     $em = $this->getDoctrine()->getManager();
     $repository = $em->getRepository('LoginLoginBundle:Users');
     if ($request->getMethod() == "POST") {
         $session->clear();
         $email = $request->get('email');
         $password = $request->get('password');
         $remember = $request->get('remember');
         $user = $repository->findOneBy(array('email' => $email, 'password' => $password));
         if ($user) {
             if ($remember == 'remember-me') {
                 $login = new Login();
                 $login->setEmail($email);
                 $login->setPassword($password);
                 $session->set('login', $login);
             }
             return $this->redirectToRoute('admin_admin_homepage');
         }
         return $this->render('LoginLoginBundle:Pages:login.html.twig');
     } else {
         if ($session->has('login')) {
             $login = $session->get('login');
             $email = $login->getEmail();
             $password = $login->getPassword();
             $user = $repository->findOneBy(array('email' => $email, 'password' => $password));
             if ($user) {
                 //return $this->render('LoginLoginBundle:Pages:login.html.twig', array('name' => $user->getName()));
                 return $this->redirectToRoute('admin_admin_homepage');
             }
         }
         return $this->render('LoginLoginBundle:Pages:login.html.twig');
     }
 }
 /**
  * @Route("/rezerwacja-biuro-podrozy", name="reserve")
  */
 public function displayAction(Request $request)
 {
     $conn = $this->get('database_connection');
     $session = new Session();
     $bool = 0;
     $msg = '';
     if ($session->has('offerId')) {
         $bool = 0;
         $oferta = $this->getDoctrine()->getRepository('AppBundle:Oferta')->findOneByIdOferta($session->get('offerId'));
     } else {
         $oferta = new Oferta();
         $bool = 1;
         $msg = 'Oferta nie istnieje!';
     }
     if ($request->getMethod() == 'POST' && $bool == 0) {
         $rezerwacja = new Rezerwacja();
         $konto = $this->getDoctrine()->getRepository('AppBundle:Konto')->findOneByLogin($session->get('name'));
         $rezerwacja->setIdKonto($konto);
         $rezerwacja->setKwota($oferta->getCena());
         $rezerwacja->setData(new \DateTime());
         $em = $this->getDoctrine()->getManager();
         $em->persist($rezerwacja);
         $em->flush();
         $msg = 'Dodano do rezerwacji!';
     }
     return $this->render('default/reserve.html.twig', array('bool' => $bool, 'message' => $msg, 'offer' => $oferta, 'session' => $session, 'base_dir' => realpath($this->container->getParameter('kernel.root_dir') . '/..')));
 }