/**
  * @param string $id
  * @return void
  */
 public function remove($id)
 {
     if (!is_string($id)) {
         throw InvalidArgumentException::invalidType('string', 'uuid', $id);
     }
     return $this->session->remove(sprintf('%s:%s', $this->namespace, $id));
 }
 /**
  * @return bool
  */
 public function removeInstallmentPayments()
 {
     if ($this->hasInstallmentPayments()) {
         $this->session->remove(self::PAYOLUTION_SESSION_IDENTIFIER);
         return true;
     }
     return false;
 }
Exemple #3
0
 public function testInitializeFromDatabase()
 {
     $this->session->remove('stack');
     $this->users->expects($this->once())->method('getCurrentUser')->willReturn(['stack' => ['a.txt']]);
     $this->filesystem->put('files://a.txt', '');
     $this->stack->getList();
     $this->assertEquals(['files://a.txt'], $this->session->get('stack'), 'Initializing stack from database should cache list in session');
 }
 /**
  * {@inheritDoc}
  */
 public function fetch(ResourceOwnerInterface $resourceOwner, $key, $type = 'token')
 {
     $key = $this->generateKey($resourceOwner, $key, $type);
     if (null === ($token = $this->session->get($key))) {
         throw new \InvalidArgumentException('No data available in storage.');
     }
     // request tokens are one time use only
     $this->session->remove($key);
     return $token;
 }
 /**
  * @param FormEvent $event
  */
 public function onFormSetData(FormEvent $event)
 {
     $error = $this->session->get(SecurityContextInterface::AUTHENTICATION_ERROR);
     // Remove error so it isnt persisted
     $this->session->remove(SecurityContextInterface::AUTHENTICATION_ERROR);
     if ($error) {
         $event->getForm()->addError(new FormError($error->getMessage()));
     }
     $event->setData(array('_username' => $this->session->get(SecurityContextInterface::LAST_USERNAME)));
 }
 /**
  * {@inheritdoc}
  */
 public function deleteCartId($cart_id)
 {
     $ids = $this->session->get('commerce_cart_orders', []);
     $ids = array_diff($ids, [$cart_id]);
     if (!empty($ids)) {
         $this->session->set('commerce_cart_orders', $ids);
     } else {
         // Remove the empty list to allow the system to clean up empty sessions.
         $this->session->remove('commerce_cart_orders');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getCart()
 {
     if (!$this->session->has($this->sessionKeyName)) {
         throw new CartNotFoundException('Sylius was not able to find the cart in session');
     }
     $cart = $this->cartRepository->findCartById($this->session->get($this->sessionKeyName));
     if (null === $cart) {
         $this->session->remove($this->sessionKeyName);
         throw new CartNotFoundException('Sylius was not able to find the cart in session');
     }
     return $cart;
 }
 /**
  * @param string $state
  * @return bool
  */
 public function isStateValid($state)
 {
     if (!$state) {
         return false;
     }
     $sessionState = $this->session->get(self::STATE_SESSION_KEY);
     $this->session->remove(self::STATE_SESSION_KEY);
     if ($state != $sessionState) {
         return false;
     }
     return true;
 }
Exemple #9
0
 protected function purgeSessionCrumbs($crumbs)
 {
     if (!$this->hasStoredCrumbs()) {
         return;
     }
     $depth = $this->getDepth($crumbs);
     $storedArray = $this->getFromSession();
     $purgedArray = $this->removeIndexesFrom($storedArray, $depth);
     if (!$purgedArray) {
         $this->session->remove($this->sessionKey);
         return;
     }
     $this->session->set($this->sessionKey, $purgedArray);
 }
 /**
  * Retrieve the CAPTCHA code
  *
  *@param $key
  *
  * @return mixed|null
  */
 protected function getExpectedCode($key)
 {
     $arrayZendSession = new SessionArrayStorage();
     if ($this->session->has($key)) {
         $sessionKey = $this->session->get($key);
         $this->session->remove($key);
         $captchaSession = $arrayZendSession->offsetGet($sessionKey);
         $arrayZendSession->offsetUnset($sessionKey);
         if ($captchaSession instanceof ArrayObject) {
             $word = $captchaSession->offsetGet('word');
             $captchaSession->offsetUnset('word');
             return $word;
         }
     }
     return null;
 }
Exemple #11
0
 /**
  * 验证并删除验证码
  * @param $input
  * @return bool
  */
 public function check($input)
 {
     $result = $this->test($input);
     //从Session中删除code
     $this->store->remove($this->getFullName());
     return $result;
 }
Exemple #12
0
 /**
  * {@inheritdoc}
  */
 public function removeToken($tokenId)
 {
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
     return $this->session->remove($this->namespace . '/' . $tokenId);
 }
 /**
  * @dataProvider setProvider
  */
 public function testRemove($key, $value)
 {
     $this->session->set('hi.world', 'have a nice day');
     $this->session->set($key, $value);
     $this->session->remove($key);
     $this->assertEquals(array('hi.world' => 'have a nice day'), $this->session->all());
 }
 /**
  * @inheritdoc
  */
 public function logout()
 {
     LoggerRegistry::debug('SitegearUserManager::logout()');
     $this->session->remove(self::SESSION_KEY_USER_EMAIL);
     $this->session->remove(self::SESSION_KEY_USER_IS_GUEST);
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function getCart()
 {
     try {
         $channel = $this->channelContext->getChannel();
     } catch (ChannelNotFoundException $exception) {
         throw new CartNotFoundException($exception);
     }
     if (!$this->session->has(sprintf('%s.%s', $this->sessionKeyName, $channel->getCode()))) {
         throw new CartNotFoundException('Sylius was not able to find the cart in session');
     }
     $cart = $this->orderRepository->findCartByIdAndChannel($this->session->get(sprintf('%s.%s', $this->sessionKeyName, $channel->getCode())), $channel);
     if (null === $cart) {
         $this->session->remove(sprintf('%s.%s', $this->sessionKeyName, $channel->getCode()));
         throw new CartNotFoundException('Sylius was not able to find the cart in session');
     }
     return $cart;
 }
Exemple #16
0
 /**
  * Remove the user data from the session and cookies.
  *
  * @return void
  */
 protected function clearUserDataFromStorage()
 {
     $this->session->remove($this->getName());
     if (!is_null($this->getRecaller())) {
         $recaller = $this->getRecallerName();
         $this->getCookieJar()->queue($this->getCookieJar()->forget($recaller));
     }
 }
 function it_throws_cart_not_found_exception_and_removes_id_from_session_when_cart_is_not_found(SessionInterface $session, OrderRepositoryInterface $orderRepository)
 {
     $session->has('session_key_name')->willReturn(true);
     $session->get('session_key_name')->willReturn(12345);
     $orderRepository->findCartById(12345)->willReturn(null);
     $session->remove('session_key_name')->shouldBeCalled();
     $this->shouldThrow(CartNotFoundException::class)->during('getCart');
 }
 function it_clears_cart_session_after_logging_out_and_return_default_handler_response(ChannelContextInterface $channelContext, ChannelInterface $channel, HttpUtils $httpUtils, Request $request, Response $response, SessionInterface $session)
 {
     $channelContext->getChannel()->willReturn($channel);
     $channel->getCode()->willReturn('WEB_US');
     $session->remove('_sylius.cart.WEB_US')->shouldBeCalled();
     $httpUtils->createRedirectResponse($request, '/')->willReturn($response);
     $this->onLogoutSuccess($request)->shouldReturn($response);
 }
Exemple #19
0
 public function buildToken(Request $req, $firewallName)
 {
     $providerKey = $req->attributes->get('provider');
     // Retrieve the temporary credentials from step 2
     $temporaryCredentials = unserialize($this->session->get(self::TEMP_CRED));
     // Third and final part to OAuth 1.0 authentication is to retrieve token
     // credentials (formally known as access tokens in earlier OAuth 1.0
     // specs).
     $tokenCredentials = $this->provider->getTokenCredentials($temporaryCredentials, $req->query->get('oauth_token'), $req->query->get('oauth_verifier'));
     $this->session->remove(self::TEMP_CRED);
     // We got an access token, let's now get the user's details
     /** @var \League\OAuth1\Client\Entity\User */
     $userDetails = $this->provider->getUserDetails($tokenCredentials);
     $internToken = new Token($firewallName, $providerKey, $userDetails->uid, [self::IDENTIFIED]);
     $internToken->setAttribute('nickname', $userDetails->nickname);
     $this->logger->debug('twitter', iterator_to_array($userDetails->getIterator()));
     return $internToken;
 }
Exemple #20
0
 /**
  * Remove a session variable
  *
  * @param string $strKey The variable name
  */
 public function remove($strKey)
 {
     // Map the referer (see #281)
     if (in_array($strKey, $this->mappedKeys)) {
         $this->session->remove($strKey);
     } else {
         $this->sessionBag->remove($strKey);
     }
 }
 /**
  * Updates the humanity
  */
 protected function updateHumanity($newValue)
 {
     if ($newValue > 0) {
         $this->session->set($this->key . '_humanity', $newValue);
     } else {
         $this->session->remove($this->key . '_humanity');
     }
     return null;
 }
Exemple #22
0
 /**
  * Remove a session variable
  *
  * @param string $strKey The variable name
  */
 public function remove($strKey)
 {
     @trigger_error('Using Session::remove() has been deprecated and will no longer work in Contao 5.0. Use the Symfony session via the container instead.', E_USER_DEPRECATED);
     // Map the referer (see #281)
     if ($strKey == 'referer') {
         $this->session->remove('referer');
     } else {
         $this->sessionBag->remove($strKey);
     }
 }
 function it_throws_cart_not_found_exception_and_removes_id_from_session_when_cart_was_not_found(SessionInterface $session, OrderRepositoryInterface $orderRepository, ChannelContextInterface $channelContext, ChannelInterface $channel)
 {
     $channelContext->getChannel()->willReturn($channel);
     $channel->getCode()->willReturn('Poland');
     $session->has('session_key_name.Poland')->willReturn(true);
     $session->get('session_key_name.Poland')->willReturn(12345);
     $orderRepository->findCartByChannel(12345, $channel)->willReturn(null);
     $session->remove('session_key_name.Poland')->shouldBeCalled();
     $this->shouldThrow(CartNotFoundException::class)->during('getCart');
 }
 /**
  * Dummy success page
  * @return Response
  */
 public function successAction()
 {
     if (!$this->session->has('cardinity_payment')) {
         return $this->errorResponse('Session expired.');
     }
     $payment = new Payment\Payment();
     $payment->unserialize($this->session->get('cardinity_payment'));
     $this->session->remove('cardinity_payment');
     return $this->templating->renderResponse('CardinityClientBundle:Payment:success.html.twig', ['payment' => $payment]);
 }
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $smtpServerId = $request->request->get('id');
     $smtpServer = $this->getRepository(SMTPServer::class)->getById($smtpServerId);
     $date = Util::getServerCurrentDateTime();
     $this->getLogger()->addInfo('DELETE SMTP Server ' . $smtpServer['name'], $this->getLoggerContext());
     $this->getRepository(SMTPServer::class)->deleteById($smtpServerId);
     $session->remove('client/settings/smtp');
     return new Response('');
 }
 /**
  * Submit handler for the "Cancel" button on the checkout form.
  */
 public function cancel(array &$form, FormStateInterface $form_state)
 {
     $order = $form_state->get('order');
     if ($this->session->get('cart_order') == $order->id()) {
         uc_order_comment_save($order->id(), 0, $this->t('Customer canceled this order from the checkout form.'));
         $this->session->remove('cart_order');
     }
     $this->session->remove('uc_checkout_review_' . $order->id());
     $this->session->remove('uc_checkout_complete_' . $order->id());
     $form_state->setRedirect('uc_cart.cart');
 }
Exemple #27
0
 /**
  * Log out the currently logged in user.
  *
  * @return boolean
  */
 public function revokeSession()
 {
     $this->flashLogger->info(Trans::__('You have been logged out.'));
     // Remove all auth tokens when logging off a user
     if ($sessionAuth = $this->session->get('authentication')) {
         $this->repositoryAuthtoken->deleteTokens($sessionAuth->getUser()->getUsername());
     }
     $this->session->remove('authentication');
     $this->session->migrate(true);
     return false;
 }
Exemple #28
0
 /**
  * Delete a session variable from the "userdata" array
  *
  * @param	array
  */
 function unset_userdata($newdata = array())
 {
     if (is_string($newdata)) {
         $newdata = array($newdata => '');
     }
     if (count($newdata) > 0) {
         foreach ($newdata as $key => $val) {
             $this->session->remove($key);
         }
     }
 }
Exemple #29
0
 /**
  * Persists the new ticket
  *
  * @param string $transactionId
  * @param string $payerId
  * @param string $payerEmail
  */
 protected function persistance($transactionId, $payerId, $payerEmail)
 {
     $this->session->remove(self::PAYPAL_TOKEN);
     $ticket = $this->repository->createTicketFromPayment();
     $ticket->setTransactionInfo(['transactionId' => $transactionId, 'payerId' => $payerId, 'payerEmail' => $payerEmail]);
     // save payment
     try {
         $this->repository->persistNewPayment($ticket);
     } catch (\Exception $e) {
         $this->logger->error(sprintf('Payment was not saved for user %s transaction %s (reason: %s)'), $this->getUser()->getUsername(), $transactionId, $e->getMessage());
     }
 }
Exemple #30
0
 /**
  * Attempts to authenticate the given user according to the passed credentials.
  *
  * @param  array $credentials
  * @return UserInterface
  * @throws BadCredentialsException
  */
 public function authenticate(array $credentials)
 {
     $this->events->dispatch(AuthEvents::PRE_AUTHENTICATE, new AuthenticateEvent($credentials));
     if (!($user = $this->getUserProvider()->findByCredentials($credentials)) or !$this->getUserProvider()->validateCredentials($user, $credentials)) {
         $this->session->set(self::LAST_USERNAME, $credentials[self::USERNAME_PARAM]);
         $this->events->dispatch(AuthEvents::FAILURE, new AuthenticateEvent($credentials, $user));
         throw new BadCredentialsException($credentials);
     }
     $this->events->dispatch(AuthEvents::SUCCESS, new AuthenticateEvent($credentials, $user));
     $this->session->remove(self::LAST_USERNAME);
     return $user;
 }