/** * Returns a user var from the session. * * @param string $name * @param null $default * * @return mixed */ public function getSessionVar($name, $default = null) { if (null === $this->session) { return $default; } return $this->session->get($name, $default); }
/** * @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')); } }
/** * @Route("/ajax/tableau",name="ajaxtab") * @Template("coffreappBundle:Default:tableau.html.twig") */ public function TableauAction() { $session = new Session(); $em = $this->getDoctrine()->getManager(); $entities = $em->getRepository('coffreappBundle:Ticket')->findBy(array('operateur' => $session->get('Codecaisse'), 'session' => $session->get('Session')), array('id' => "desc")); return array('entity' => $entities); }
/** * @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); }
/** * @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') . '/..'))); }
/** * CartProvider constructor. * @param Session $session * @param EntityManagerInterface $entityManager * @param $parameters */ public function __construct(Session $session, EntityManagerInterface $entityManager, $parameters) { $this->parameters = $parameters; $this->session = $session; $this->cart = $this->session->get('cart'); $this->entityManager = $entityManager; }
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'); }*/ }
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; }
/** * {@inheritdoc} */ public function loadUserByUsername($username, $password = null) { // if the password is not passed in, we have arrived here from a login form, so grab it from the request if (null === $password) { $password = Request::createFromGlobals()->get('_password'); } $credentials = array('email' => $username, 'password' => $password); $client = $this->irisEntityManager->getClient(); // use the MAC in the session to access the cached system credentials $authData = $this->session->get('auth-data'); if (!$client->hasValidCredentials($authData->get('systemKey'), $authData->get('systemSecret'))) { throw new BadCredentialsException('Invalid System credentials for IRIS'); } // attempt to authenticate and get the Landlords key and secret if (false === ($oauthCredentials = $client->assume($credentials))) { // invalid credentials throw new UsernameNotFoundException('Invalid Landlord credentials for IRIS'); } // create the User to return it to be stored in the session $user = new LandlordUser($authData->get('systemKey'), $authData->get('systemSecret'), $username, $password); // manually set the consumer key and secret as the username and password do not represent them $user->setConsumerKey($oauthCredentials['consumerKey']); $user->setConsumerSecret($oauthCredentials['consumerSecret']); return $user; }
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(); } } }
/** * * @return array */ public function getChoices() { if ($this->sessionManager->has('choices')) { return $this->sessionManager->get('choices'); } return []; }
public function __construct(Session $session, Connection $conn) { //Fetching equipment requests count $stmt = $conn->prepare("SELECT dept_name FROM staff where user_id =:user_id;"); $stmt->bindValue(':user_id', $session->get('user_id')); $stmt->execute(); $staff_member = $stmt->fetch()['dept_name']; $stmt = $conn->prepare('SELECT COUNT(DISTINCT request_id) AS count FROM resource_request WHERE (resource_request.resource_id is NULL OR resource_request.resource_id IN (SELECT resource_id FROM equipment)) AND resource_request.department_name = :dept_name AND resource_request.status = 2 AND date_from >= CURDATE();'); $stmt->bindValue(':dept_name', $staff_member); $stmt->execute(); $this->equipment_requests_count = $stmt->fetch()['count']; //Fetching venues requests count $stmt = $conn->prepare('CREATE OR REPLACE VIEW admin_resource_view as select venue.resource_id from venue INNER JOIN resource_administration on venue.resource_id = resource_administration.resource_id and resource_administration.user_id = :user_id;'); $stmt->bindValue(':user_id', $session->get('user_id')); $stmt->execute(); $stmt = $conn->prepare('SELECT COUNT(DISTINCT request_id) AS count FROM resource_request INNER JOIN view1 using(resource_id) WHERE status = 2 AND date_from >= CURDATE();'); $stmt->execute(); $this->venue_requests_count = $stmt->fetch()['count']; //Fetching vehicle requests count $stmt = $conn->prepare('SELECT COUNT(DISTINCT vehicle_request.request_id) AS count FROM (vehicle_request INNER JOIN vehicle ON vehicle.type = vehicle_request.requested_type) INNER JOIN vehicle_administration ON vehicle.plate_no = vehicle_administration.plate_no WHERE vehicle_administration.user_id = :user_id AND vehicle_request.status = 2 AND date >= CURDATE();'); $stmt->bindValue(':user_id', $session->get('user_id')); $stmt->execute(); $this->vehicle_requests_count = $stmt->fetch()['count']; //Fetching access level $stmt = $conn->prepare('SELECT access_level FROM login INNER JOIN user USING(user_id) WHERE user_id = :user_id AND active = true;'); $stmt->bindValue(':user_id', $session->get('user_id')); $stmt->execute(); $this->access_level = $stmt->fetch()['access_level']; }
/** * {@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); }
/** * @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()); } }
/** * @param \Symfony\Component\HttpFoundation\Session\Session $session */ public function handleSessionValidation(SymfonySession $session) { $ip_address = new IPAddress($this->request->getClientIp()); $request_ip = $ip_address->getIp(IPAddress::FORMAT_IP_STRING); $invalidate = false; $ip = $session->get('CLIENT_REMOTE_ADDR'); $agent = $session->get('CLIENT_HTTP_USER_AGENT'); $request_agent = $this->request->server->get('HTTP_USER_AGENT'); // Validate the request IP if ($this->shouldCompareIP() && $ip && $ip != $request_ip) { if ($this->logger) { $this->logger->debug('Session Invalidated. Session IP "{session}" did not match provided IP "{client}".', array('session' => $ip, 'client' => $request_ip)); } $invalidate = true; } // Validate the request user agent if ($this->shouldCompareAgent() && $agent && $agent != $request_agent) { if ($this->logger) { $this->logger->debug('Session Invalidated. Session user agent "{session}" did not match provided agent "{client}"', array('session' => $agent, 'client' => $request_agent)); } $invalidate = true; } if ($invalidate) { $session->invalidate(); } else { if (!$ip && $request_ip) { $session->set('CLIENT_REMOTE_ADDR', $request_ip); } if (!$agent && $request_agent) { $session->set('CLIENT_HTTP_USER_AGENT', $request_agent); } } }
/** * Returns all products in a cart * @return array|null */ public function getAllCartProducts() { $cartID = $this->session->get('cartID'); $query = "\n SELECT\n cp.id, cp.unit_price, cp.quantity, p.id AS product_id, p.name, p.image, p.slug\n FROM\n aca_cart_product AS cp\n INNER JOIN aca_product AS p ON cp.product_id = p.id\n WHERE cp.cart_id = :cartID\n "; $result = $this->db->fetchRowMany($query, array('cartID' => $cartID)); return $result; }
public function getUserDataHeader(Session $session) { if (!$session->has('userId')) { return null; } return ['name' => $session->get('userName'), 'secondName' => $session->get('userSName'), 'role' => $session->get('userRole')]; }
/** * @param string $name * @param \Spryker\Shared\Transfer\TransferInterface $transferObject * * @return \Spryker\Shared\Transfer\TransferInterface */ public function get($name, TransferInterface $transferObject) { $transferArray = $this->session->get($name); if (!empty($transferArray)) { $transferObject->fromArray($transferArray, true); } return $transferObject; }
public function check() { if (strtolower($this->request->get("captcha")) != strtolower($this->session->get("captcha"))) { return true; } else { return false; } }
public function testGetStateWithGeneration() { $state = $this->stateStore->getState(); $this->assertInternalType('string', $state); $this->assertNotEmpty($state); $this->assertEquals($state, $this->session->get(StateStore::KEY_STATE)); $this->assertEquals($state, $this->stateStore->getState()); }
public function testUpdateFromTokenResponse() { $this->given->iHaveRandomOtherDataInMySession($this->tokenSession, ['foo' => 'bar']); $rawTokenResponse = $this->given->rawTokenResponse('123', new Scope(['read'])); $tokenResponse = new TokenResponse($rawTokenResponse); $this->tokenStore->updateFromTokenResponse($tokenResponse); $this->assertEquals('bar', $this->tokenSession->get('foo')); }
public function buildForm(FormBuilderInterface $builder, array $options) { $user = $this->securityContext->getToken()->getUser(); if ($user === 'anon.') { $user = false; } $builder->add('clientFirstName', null, array('attr' => array('placeholder' => 'Иван', 'class' => 'input_block'), 'label' => 'Имя', 'data' => $user ? $user->getFirstname() : ''))->add('clientLastName', null, array('attr' => array('placeholder' => 'Иванов', 'class' => 'input_block'), 'label' => 'Фамилия', 'data' => $user ? $user->getLastname() : ''))->add('telephone', null, array('attr' => array('placeholder' => '+7 910 001 10 10', 'class' => 'input_block'), 'label' => 'Телефон', 'data' => $user ? $user->getPhone() : ''))->add('email', EmailType::class, array('attr' => array('placeholder' => '*****@*****.**', 'class' => 'input_block'), 'label' => 'E-mail', 'data' => $user ? $user->getEmail() : ''))->add('address', new AddressOrderType(), array('label' => false, 'required' => false, 'data_class' => 'ShopBundle\\Entity\\AddressOrder'))->add('wishes', null, array('label' => 'Ваши пожелания'))->add('deliveryType', 'hidden', array('data' => DeliveryType::PICKUP))->add('products', 'hidden', array('data' => $this->session->get('ids')))->add('summ', 'hidden', array('data' => $this->session->get('basketSumm')))->add('bonus', 'hidden', array('data' => 0)); }
public function getLoadCitiesApiUri() { $uri = $this->chromediaApiUrl . '/cities'; if ($institutionId = $this->session->get('institutionId')) { $uri .= "?institution_id={$institutionId}"; } return $uri; }
/** * @return string */ public function getLocale() { if ($this->hasLocale()) { return $this->session->get('admin-locale'); } else { return $this->getDefaultLocale(); } }
/** * 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; }
public function getSuccessRedirectUrl() { if ($this->session->get('redir')) { $redirectUrl = $this->session->get('redir'); $this->session->remove('redir'); return $redirectUrl; } return $this->router->generate($this->googleAuthConfiguration->getSuccessAuthorizationRedirectUrl()); }
/** * Returns value for given name * * @param string $name * @return mixed */ public function get($name) { if ($this->container instanceof WP_Session) { $value = $this->container->offsetGet($name); } else { $value = $this->container->get($name); } return $value; }
/** * 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 []; }
protected function getMessageBag() : MessageBag { $messageBag = $this->session->get(self::SESSION_ID); if ($messageBag === null) { return new MessageBag(); } $this->session->remove(self::SESSION_ID); return $messageBag; }
/** * @return ConnectionStore */ private function getStore() { $store = $this->session->get(self::CONNECTION_STORE_SESSION_INDEX, null); if (!$store) { $store = new ConnectionStore(); $this->session->set(self::CONNECTION_STORE_SESSION_INDEX, $store); } return $store; }