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();
         }
     }
 }
Example #2
0
 /**
  * Sets the authentication flag.
  *
  * @param bool $authenticated The authentication status
  */
 public function setAuthenticated($authenticated)
 {
     if (true === $authenticated) {
         $this->session->set('_auth_until', time() + $this->timeout);
     } else {
         $this->session->remove('_auth_until');
     }
 }
 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());
 }
Example #4
0
 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;
 }
Example #5
0
 /**
  * Clears the storage
  *
  * @return void
  */
 public function clear()
 {
     if ($this->session->isStarted()) {
         $this->session->remove(self::SESSION_STO_KEY . '-' . $this->namespace);
     }
     if ($this->isApplyStrategy()) {
         $this->applySessionStrategy();
     }
 }
Example #6
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;
 }
Example #7
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');
     }
 }
Example #8
0
 /**
  * @param boolean $destroy
  *
  * @return boolean
  */
 public function logout($destroy = false)
 {
     if ($destroy === true) {
         $this->session->invalidate();
     } else {
         $this->session->remove(self::USER_ID);
         $this->session->remove(self::USER_NAME);
         $this->session->remove(self::USER_GROUPS);
         $this->session->migrate();
     }
     return !$this->isLogin();
 }
Example #9
0
 public function set($name, $value = null)
 {
     if (is_null($value)) {
         $this->profiler->debug('session.remove.' . $name);
         $this->session->remove($value);
     } else {
         if ($value instanceof Entity) {
             $value = $value->export();
         }
         $this->profiler->debug('session.set.' . $name, $value);
         $this->session->set($name, $value);
     }
 }
 /**
  * Methode permettant de suprimmer un élement dans les uploads dans la session
  *
  * @param int $id id de la pièce
  */
 public function unsetUpload($id)
 {
     if (array_key_exists('uploads', $this->session->all())) {
         $uploads = $this->session->get('uploads');
         $key = array_search(intval($id), $uploads);
         if (is_numeric($key)) {
             unset($uploads[$key]);
             if (empty($uploads)) {
                 $this->session->remove('uploads');
             } else {
                 $this->session->set('uploads', $uploads);
             }
         }
     }
 }
Example #11
0
 /**
  * 验证并删除验证码
  * @param $input
  * @return bool
  */
 public function check($input)
 {
     $result = $this->test($input);
     //从Session中删除code
     $this->store->remove($this->getFullName());
     return $result;
 }
Example #12
0
 /**
  * Removes a variable from the session.
  *
  * @param $name
  */
 public function unsetVar($name)
 {
     if (null === $this->session) {
         return;
     }
     $this->session->remove($name);
 }
 /**
  * @Route("/getuploadfile", name="_getuploadfile")
  */
 public function getUploadFileAction()
 {
     $Session = new Session();
     echo json_encode($Session->get('comment_id'));
     $Session->remove('comment_id');
     die;
 }
Example #14
0
 /**
  * Removes the named value
  *
  * @param string $name
  * @return void
  */
 public function remove($name)
 {
     if ($this->container instanceof WP_Session) {
         $this->container->offsetUnset($name);
     } else {
         $this->container->remove($name);
     }
 }
Example #15
0
 public function getMessage(Session $session)
 {
     $message = null;
     if ($session->has('message')) {
         $message = $session->get('message');
         $session->remove('message');
     }
     return $message;
 }
Example #16
0
 /**
  * Remove all session variables upon logout
  */
 public function logout()
 {
     $this->session->remove('loggedIn');
     $this->session->remove('name');
     $this->session->remove('username');
     $this->session->remove('password');
     $this->session->remove('user_id');
     $this->session->save();
 }
Example #17
0
 /**
  * When redirecting to login page set the 'retreat' variable in the session.
  * This allows a redirect back to the current page after successful login.
  *
  * @param \Symfony\Component\HttpFoundation\Request          $request
  * @param \Symfony\Component\HttpFoundation\RedirectResponse $response
  */
 protected function handleLoginRetreat(Request $request, RedirectResponse $response)
 {
     $route = $request->attributes->get('_route');
     if ($response->getTargetUrl() === $this->urlGenerator->generate('login') && $route !== 'logout') {
         $this->session->set('retreat', ['route' => $route, 'params' => $request->attributes->get('_route_params')]);
     } else {
         $this->session->remove('retreat');
     }
 }
Example #18
0
 public function save()
 {
     $pkg = Package::getByHandle('problog');
     $PB_APP_KEY = $pkg->getConfig()->get('api.twitter_app_key', false);
     $PB_APP_SECRET = $pkg->getConfig()->get('api.twitter_app_secret', false);
     $session = new SymfonySession();
     /* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
     $connection = new TwitterOAuth($PB_APP_KEY, $PB_APP_SECRET, $session->get('problog.twitter.oauth_token'), $session->get('problog.twitter.oauth_token_secret'));
     /* Request access tokens from twitter */
     $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
     /* Save the access tokens. Normally these would be saved in a database for future use. */
     $session->set('problog.twitter.access_token', $access_token);
     /* Remove no longer needed request tokens */
     $session->remove('problog.twitter.oauth_token');
     $session->remove('problog.twitter.oauth_token_secret');
     $pkg = Package::getByHandle('problog');
     $pkg->getConfig()->save('api.twitter_auth_token', $access_token['oauth_token']);
     $pkg->getConfig()->save('api.twitter_auth_secret', $access_token['oauth_token_secret']);
     header("Location: " . URL::to('dashboard/problog/settings/'));
     die;
 }
Example #19
0
 /**
  * @param BlockInterface $block
  *
  * @return array
  */
 public function getViewParameters(BlockInterface $block)
 {
     $authErrorKey = Security::AUTHENTICATION_ERROR;
     $lastUsernameKey = Security::LAST_USERNAME;
     // get the error if any (works with forward and redirect -- see below)
     if ($this->getRequest()->attributes->has($authErrorKey)) {
         $error = $this->getRequest()->attributes->get($authErrorKey);
     } elseif (null !== $this->session && $this->session->has($authErrorKey)) {
         $error = $this->session->get($authErrorKey);
         $this->session->remove($authErrorKey);
     } else {
         $error = null;
     }
     if (!$error instanceof AuthenticationException) {
         $error = null;
         // The value does not come from the security component.
     }
     // last username entered by the user
     $lastUsername = null === $this->session ? '' : $this->session->get($lastUsernameKey);
     $csrfToken = $this->csrfTokenManager->getToken('authenticate')->getValue();
     $parameters = ['block_service' => $this, 'block' => $block, 'last_username' => $lastUsername, 'error' => $error, 'csrf_token' => $csrfToken];
     return $parameters;
 }
Example #20
0
 /**
  * Ausgabe der durch Filtern übergebene Liste
  *
  * @param object $request Request von der vorhergehenden Seite
  *
  * @return html Ausgabe des Schnippsels
  */
 public function loadAjaxDataAction(Request $request)
 {
     $req = $request->request->get('ajax');
     if (!empty($req)) {
         switch ($request->request->get('ajax')) {
             case "transactions":
                 $value = $request->request->get('value');
                 if ($request->request->get('filter') == "t.starttimestamp" || $request->request->get('filter') == "t.stoptimestamp") {
                     $value = HelpController::formatDate($value);
                 }
                 $session_filter = new Session();
                 $session_filter->start();
                 if ($value != "*") {
                     $session_filter->set($request->request->get('filter'), $value);
                 } else {
                     $session_filter->remove($request->request->get('filter'));
                 }
                 $array_filter = array($request->request->get('filter') => $value);
                 $transactions = $this->getDoctrine()->getRepository('SteveFrontendBundle:Transaction')->getTransaction($session_filter->all());
                 $array_render = array('transactions' => $transactions);
                 $template = $this->renderView("SteveFrontendBundle:Ajax:listtransactions.html.twig", $array_render);
                 break;
             case "users":
                 $users = $this->getDoctrine()->getRepository('SteveFrontendBundle:User')->findAll();
                 $array_render = array('users' => $users);
                 $template = $this->renderView("SteveFrontendBundle:Ajax:listuser.html.twig", $array_render);
                 break;
             case "chargepoint":
                 /* setzt bzw. Update eventuell hier noch verschieben */
                 $transaction_id = $request->request->get('transaction_id');
                 $chargeBoxId = $request->request->get('chargeBoxId');
                 $chargebox = $this->getDoctrine()->getRepository('SteveFrontendBundle:Chargebox')->find($chargeBoxId);
                 $em = $this->getDoctrine()->getManager();
                 $transactions = $em->getRepository('SteveFrontendBundle:Transaction')->find($transaction_id);
                 if (!$transactions) {
                     throw $this->createNotFoundException('No Transfer found for id ' . $transaction_id);
                 }
                 $now = new DateTime("now");
                 $transactions->setStopvalue($transactions->getStartvalue());
                 $transactions->setStoptimestamp($now);
                 $em->flush();
                 $array_render = OutputController::createContentChargebox(null, $chargeBoxId);
                 $template = $this->renderView('SteveFrontendBundle:Ajax:listchargebox.html.twig', $array_render);
                 break;
             default:
                 break;
         }
     }
     return new Response($template);
 }
Example #21
0
 public function resetSession()
 {
     //Ré-init sync
     if ($this->session->has(self::SESSION_PARAMETERS_KEY)) {
         $this->session->remove(self::SESSION_PARAMETERS_KEY);
     }
     if ($this->session->has(self::SESSION_FROM_KEY)) {
         $this->session->remove(self::SESSION_FROM_KEY);
     }
     if ($this->session->has(self::SESSION_TO_KEY)) {
         $this->session->remove(self::SESSION_TO_KEY);
     }
     if ($this->session->has(self::SESSION_WEIGHT_COLLECTION_KEY)) {
         $this->session->remove(self::SESSION_WEIGHT_COLLECTION_KEY);
     }
     $this->parameters = new Parameters();
     $this->parameters->setMaxNbLinesToInsert(1000);
     $this->parameters->setManagerFrom('prod');
     $this->parameters->setManagerTo('preprod');
     $this->parameters->setTestSchema(true);
     $this->parameters->setInsertData(false);
     $this->parameters->setSyncChild(false);
 }
Example #22
0
 /**
  * Read the user from the session
  */
 private function readUserFromSession()
 {
     $userId = $this->session->get(self::USER_ID);
     if (!$userId) {
         // No user id, not signed in
         return;
     }
     $user = $this->userStorage->getUserById($userId);
     if (!$user) {
         // Malformed user session, removing the user id
         $this->session->remove(self::USER_ID);
         return;
     }
     $this->user = $user;
 }
Example #23
0
 public function isValid($input)
 {
     if (!is_scalar($input)) {
         return false;
     }
     if (!$this->config['case_sensitive']) {
         $input = strtoupper($input);
     }
     if (empty($this->config['hash_algo'])) {
         $input_hash = hash('sha1', $input);
     } else {
         $input_hash = hash($this->config['hash_algo'], $input);
     }
     $saved_captcha = $this->session->get('innocead.captcha.code');
     if ($input_hash == $saved_captcha) {
         $this->session->remove('innocead.captcha.code');
         $this->session->remove('innocead.captcha.last_request');
         $this->session->remove('innocead.captcha.queries');
         return true;
     } else {
         return false;
     }
     return false;
 }
 /**
  * @Route("/", name="homepage")
  */
 public function indexAction(Request $request)
 {
     $session = $request->getSession();
     if ($session == null) {
         $session = new Session();
     }
     if (!$session->isStarted()) {
         $session->start();
     }
     //new sessionID if session existed already.
     $session->migrate();
     if ($session->has('originalSessionID')) {
         $session->remove('originalSessionID');
     }
     return $this->render('default/index.html.twig');
 }
 public function environmentSessionController(FilterControllerEvent $event)
 {
     $securityChecker = $this->container->get('security.authorization_checker');
     $controller = $event->getController();
     $session = new Session();
     $environment = $session->get('environment');
     $request = $event->getRequest();
     /*
     if ($request->get('_route') == '') {
     	$redirectInit = '/init';
     	$event->setController(function() use ($redirectInit) {
     			return new RedirectResponse($redirectInit);
     		});
     }
     */
     if (isset($environment)) {
         if ($controller[0] instanceof InitController) {
             if ($securityChecker->isGranted('IS_AUTHENTICATED_FULLY')) {
                 $redirectUrl = '/menu';
                 $event->setController(function () use($redirectUrl) {
                     return new RedirectResponse($redirectUrl);
                 });
             } else {
                 if ($controller[0] instanceof SecurityController) {
                     return;
                 } else {
                     $environment = $session->remove('environment');
                     $redirectUrl = '/init';
                     $event->setController(function () use($redirectUrl) {
                         return new RedirectResponse($redirectUrl);
                     });
                 }
             }
         }
     } else {
         if (!$controller[0] instanceof InitController) {
             $redirectUrl = '/init';
             $event->setController(function () use($redirectUrl) {
                 return new RedirectResponse($redirectUrl);
             });
         } else {
             return;
         }
     }
 }
 private function handleTargetPath(GetResponseEvent $event)
 {
     $route = $event->getRequest()->get('_route');
     if ($route !== 'lc_home' && $route !== 'fos_user_security_login') {
         return;
     }
     $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');
     }
     return $this->redirectUrl($url);
 }
 /**
  * @route(
  *      path = "/",
  *      name = "index"
  * ) 
  */
 public function showAction(Request $request)
 {
     $session = new Session();
     /*if ($this->getUser()) { //user ophalen van FOS UserBundle
           echo($this->getUser()->getId());
       }*/
     if ($request->query->get("action")) {
         //checkt of er uitgelogd wordt
         if ($request->query->get("action") == "uitloggen") {
             $session->set("aangemeld", false);
             $session->remove("winkelmandje");
             $session->set("prijs", 0);
             return $this->redirect($this->generateUrl('index'));
         }
     }
     /* Niet gedefiniëerde variabele een waarde geven om notice te voorkomen */
     if (!$session->has("login")) {
         $session->set("login", "niet ingelogd");
     }
     error_reporting(E_ALL & ~E_NOTICE);
     return $this->render("Pizzeria/index.html.twig", array("aangemeld" => $this->getUser(), "login" => $session->get("login")));
 }
 /**
  * @param Request        $request
  * @param TokenInterface $token
  *
  * @return Response
  */
 public function onAuthenticationSuccess(Request $request, TokenInterface $token)
 {
     //if ($request->isXmlHttpRequest()) {
     // in case of successful authentication, user must be in the context
     $user = $this->securityContext->getToken()->getUser();
     $id = $user->getId();
     $name = $user->getName();
     $email = $user->getEmail();
     $avatarimg = $user->getImg();
     $shortBio = $user->getInterviewCaption();
     $profession = $user->getJob();
     $self_link = $user->getHomepage();
     $interest = $user->getInterest();
     $last_publish_date = $user->getName();
     $dreamProfession = $user->getDream();
     $post = $this->em->getRepository('Yasoon\\Site\\Entity\\PostEntity')->createQueryBuilder('p')->leftJoin('p.author', 'a')->where('a.id = ' . $id)->setMaxResults(1)->setFirstResult(0)->orderBy('p.date', 'desc')->getQuery()->getResult();
     if ($post) {
         $post_date = $post[0]->getDate()->format('d/m/Y');
     } else {
         $post_date = null;
     }
     //$user->getPosts()->findAll();
     $userdata = ['id' => $id, 'name' => $name, 'email' => $email, 'avatarimg' => $avatarimg, 'shortBio' => $shortBio, 'profession' => $profession, 'self_link' => $self_link, 'interest' => $interest, 'last_publish_date' => $post_date, 'dreamProfession' => $dreamProfession];
     $session = new Session();
     if (!empty($session->get('reviewStatus'))) {
         $reviewId = $session->get('reviewStatus');
         $review = $this->em->getRepository('Yasoon\\Site\\Entity\\ReviewEntity')->find($reviewId);
         $review->setStatus('saved')->setAuthorId($id);
         $this->em->merge($review);
         $this->em->flush();
         $session->remove('reviewStatus');
         return new JsonResponse(['error' => 'false', 'userData' => $userdata, 'reviewId' => $reviewId], 200);
     }
     return new JsonResponse(['error' => 'false', 'userData' => $userdata], 200);
     //}
     return parent::onAuthenticationSuccess($request, $token);
 }
Example #29
0
 /**
  * @inheritDoc
  */
 public function clearCart()
 {
     $this->session->remove(self::NAME);
 }
 /**
  * @route(
  *      path = "/afrekenen",
  *      name = "afrekenen_show"
  * ) 
  */
 public function afrekenenAction(Request $request)
 {
     $session = new Session();
     if ($this->getUser()) {
         //checkt of er een klant is aangemeld
         $klant = $this->get("doctrine")->getmanager()->getRepository("AppBundle:Klant")->find($this->getUser()->getId());
     }
     if ($request->query->get("verwijder")) {
         //checkt of er een item uit winkelmandje moet verwijderd worden
         $verwijder = $request->query->get("verwijder");
         // id van product dmv key uit de array winkelmandje
         $winkelmandje = $session->get("winkelmandje");
         $verwijderId = $winkelmandje[$verwijder]->getId();
         $verwijderproduct = $this->get("doctrine")->getmanager()->getRepository("AppBundle:Product")->find($verwijderId);
         if (isset($klant) && $klant->getPromotie() == 1) {
             // checkt of klant promotie krijgt
             $session->set("prijs", $session->get("prijs") - $verwijderproduct->getPromotie());
         } else {
             $session->set("prijs", $session->get("prijs") - $verwijderproduct->getPrijs());
         }
         unset($winkelmandje[$verwijder]);
         $session->set("winkelmandje", $winkelmandje);
         return $this->redirect($this->generateUrl('afrekenen_show'));
     }
     if ($request->query->get("besteld")) {
         //bestellingsgegevens in juiste tabellen zetten
         $datetime = new DateTime("now");
         $bestelling = new Bestelling();
         $bestelling->setKlantid($this->getUser()->getId());
         $bestelling->setPrijs($session->get("prijs"));
         $bestelling->setDatum($datetime);
         $em = $this->getDoctrine()->getManager();
         $em->persist($bestelling);
         $em->flush();
         $bestellingId = $bestelling->getId();
         foreach ($session->get("winkelmandje") as $product) {
             $bestreg = new Bestelregel();
             if ($klant->getPromotie() == 1) {
                 //checkt of promotieprijs of gewone prijs aan bestreg moet meegegeven worden
                 $bestreg->setBestelid($bestellingId);
                 $bestreg->setProductid($product->getId());
                 $bestreg->setPrijs($product->getPromotie());
             } else {
                 $bestreg->setBestelid($bestellingId);
                 $bestreg->setProductid($product->getId());
                 $bestreg->setPrijs($product->getPrijs());
             }
             $em = $this->getDoctrine()->getManager();
             $em->persist($bestreg);
             $em->flush();
         }
         return $this->redirect($this->generateUrl('afrekenen_show', array("bestelcheck" => "true")));
     }
     if ($request->query->get("bestelcheck")) {
         //checkt of bestelling is geplaatst om overzicht te tonen
         $bestelcheck = true;
         $session->remove("winkelmandje");
         $session->set("prijs", 0);
         $producten = $this->get("doctrine")->getmanager()->getRepository("AppBundle:Product")->findAll();
         $bestelling = $this->get("doctrine")->getmanager()->createQuery("SELECT b FROM AppBundle:Bestelling b WHERE b.klantid = " . $this->getUser()->getId() . " ORDER BY b.datum DESC")->setMaxResults(1)->getSingleResult();
         $bestregels = $this->get("doctrine")->getmanager()->getRepository("AppBundle:Bestelregel")->findByBestelid($bestelling->getId());
     }
     /* Alle niet gedefiniëerde variabelen een waarde geven om notice te voorkomen */
     if (!isset($klant)) {
         $klant = null;
     }
     if (!isset($bestelling)) {
         $bestelling = null;
     }
     if (!isset($bestregels)) {
         $bestregels = null;
     }
     if (!isset($producten)) {
         $producten = null;
     }
     if (!isset($bestelcheck)) {
         $bestelcheck = false;
     }
     if (!$session->has("winkelmandje")) {
         $session->set("winkelmandje", []);
     }
     return $this->render("Pizzeria/afrekening.html.twig", array("winkelmandje" => $session->get("winkelmandje"), "totaalprijs" => $session->get("prijs"), "aangemeld" => $this->getUser(), "bestelcheck" => $bestelcheck, "bestelling" => $bestelling, "bestregels" => $bestregels, "producten" => $producten, "klant" => $klant));
 }