/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if (!$this->session->has('customer_id')) { return redirect()->to('admin'); } return $next($request); }
public function getURL($name) { if ($this->sessionManager->has($name = $this->getName($name))) { return $this->sessionManager->get($name); } return false; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->session->has($this->sessionKey)) { $this->googleTagManager->set($this->session->get($this->sessionKey)); } $response = $next($request); $this->session->flash($this->sessionKey, $this->googleTagManager->getFlashData()); return $response; }
/** * Create a new flash notifier instance. * * @param Store $session */ public function __construct(Store $session) { if ($session->has('flash_notification.messages')) { $session->forget('flash_notification.messages'); } if ($session->has('flash_notification.important')) { $session->forget('flash_notification.important'); } $this->session = $session; }
/** * Renders the age gate view */ public function agegate() { $previousTooYoung = $this->session->get('laravel-avp.previous_too_young'); $view = view(config('agegate.view'))->with(compact('previousTooYoung')); if (!$this->session->has('errors') && $previousTooYoung) { $messages = $this->lang->get('laravel-avp::validation.custom'); $errorMsg = $messages['dob.previous']; $view->withErrors(['dob' => [$errorMsg]]); } return $view; }
public function __construct(Store $session, Factory $view) { $this->session = $session; $view->share('flash', $this); if ($this->session->has($this->namespace)) { $flashed = $this->session->get($this->namespace); $this->message = $flashed['message']; $this->title = $flashed['title']; $this->type = $flashed['type']; $this->exists = true; } }
/** * Create a new flash notifier instance. * * @param Store $session * @param Application $app */ function __construct(Store $session, Application $app) { $this->session = $session; $this->app = $app; $this->messages = $this->session->pull('__messages', new Collection()); if ($this->session->has('errors')) { $errors = $this->session->get('errors')->getBag('default')->getMessages(); foreach ($errors as $error) { $this->add(['message' => current($error), 'type' => 'info', 'class' => 'warning'], false); } } }
/** * Populate the fields with entry values. * * @param FormBuilder $builder */ public function populate(FormBuilder $builder) { $fields = $builder->getFields(); $entry = $builder->getFormEntry(); foreach ($fields as &$field) { /* * If the field is not already set * then get the value off the entry. */ if (!isset($field['value']) && $entry instanceof EloquentModel && $entry->getId()) { if ($locale = array_get($field, 'locale')) { $field['value'] = $entry->translateOrDefault($locale)->{$field['field']}; } else { $field['value'] = $entry->{$field['field']}; } } /* * If the field has a default value * and the entry does not exist yet * then use the default value. */ if (isset($field['config']['default_value']) && $entry instanceof EloquentModel && !$entry->getId()) { $field['value'] = $field['config']['default_value']; } /* * If the field has a default value * and there is no entry then * use the default value. */ if (isset($field['config']['default_value']) && !$entry) { $field['value'] = $field['config']['default_value']; } /* * If the field is an assignment then * use it's config for the default value. */ if (!isset($field['value']) && $entry instanceof EntryInterface && ($type = $entry->getFieldType($field['field']))) { $field['value'] = array_get($type->getConfig(), 'default_value'); } /* * Lastly if we have flashed data from a front end * form handler then use that value for the field. */ if ($this->session->has($field['prefix'] . $field['field'])) { $field['value'] = $this->session->pull($field['prefix'] . $field['field']); } } $builder->setFields($fields); }
/** * The constructor * * @param HtmlBuilder $html * @param UrlGenerator $url * @param Session $session */ public function __construct(HtmlBuilder $html, UrlGenerator $url, Session $session) { parent::__construct($html, $url, $session->getToken()); $this->session = $session; $this->requiredFields = []; $this->errorFields = []; if ($this->session->has('formhelper-required-fields')) { $this->requiredFields = $this->session->get('formhelper-required-fields'); $this->session->forget('formhelper-required-fields'); } if ($this->session->has('formhelper-error-fields')) { $this->errorFields = $this->session->get('formhelper-error-fields'); $this->session->forget('formhelper-error-fields'); } }
/** * Retrieve Message instance from Session, the data should be in * serialize, so we need to unserialize it first. * * @return self */ public function retrieve() { $messages = null; if (!isset($this->instance)) { $this->instance = new static(); $this->instance->setSessionStore($this->session); if ($this->session->has('message')) { $messages = @unserialize($this->session->get('message', '')); } $this->session->forget('message'); if (is_array($messages)) { $this->instance->merge($messages); } } return $this->instance; }
/** * Get the cart. * * @return Cart */ public function getCart() { if ($this->session->has('cart')) { return $this->session->get('cart'); } return $this->cart; }
/** * Prepare and get the alert collection. * * Here we make sure that the alerts collection is in the session * store. If it's not, then we will go ahead an create a new one * * @return Collection */ protected function prepareAndGet() { if (!$this->session->has('chromabits.alerts')) { $this->session->set('chromabits.alerts', new Collection()); } return $this->session->get('chromabits.alerts'); }
public function __construct($config = [], SessionStore $session) { if (is_array($config['ttwitter::config'])) { $this->tconfig = $config['ttwitter::config']; } else { if (is_array($config['ttwitter'])) { $this->tconfig = $config['ttwitter']; } else { throw new Exception('No config found'); } } $this->debug = isset($this->tconfig['debug']) && $this->tconfig['debug'] ? true : false; $this->parent_config = []; $this->parent_config['consumer_key'] = $this->tconfig['CONSUMER_KEY']; $this->parent_config['consumer_secret'] = $this->tconfig['CONSUMER_SECRET']; $this->parent_config['token'] = $this->tconfig['ACCESS_TOKEN']; $this->parent_config['secret'] = $this->tconfig['ACCESS_TOKEN_SECRET']; if ($session->has('access_token')) { $access_token = $session->get('access_token'); if (is_array($access_token) && isset($access_token['oauth_token']) && isset($access_token['oauth_token_secret']) && !empty($access_token['oauth_token']) && !empty($access_token['oauth_token_secret'])) { $this->parent_config['token'] = $access_token['oauth_token']; $this->parent_config['secret'] = $access_token['oauth_token_secret']; } } $this->parent_config['use_ssl'] = $this->tconfig['USE_SSL']; $this->parent_config['user_agent'] = 'LTTW ' . parent::VERSION; $config = array_merge($this->parent_config, $this->tconfig); parent::__construct($this->parent_config); }
public function __construct(Store $session, $messages = array()) { $this->session = $session; if ($session->has($this->session_key)) { $messages = array_merge_recursive($session->get($this->session_key), $messages); } parent::__construct($messages); }
/** * Class constructor. * * @param Illuminate\Html\FormBuilder $builder * @param Illuminate\Http\Request $request * @param Illuminate\Session\Store $session */ public function __construct(Builder $builder, Request $request, Session $session) { $this->builder = $builder; $this->request = $request; $this->fields = new FieldCollection(); $this->fields->setNamespace($this->namespace); $this->fields->setBuilder($this->builder); $this->fields->setErrorBag($session->has('errors') ? $session->get('errors')->getBag($this->namespace) : new MessageBag()); }
/** * @param \Illuminate\Session\Store $session * @param \Illuminate\Config\Repository $config * @param array $messages * @return \Prologue\Alerts\AlertsMessageBag */ public function __construct(Session $session, Config $config, array $messages = []) { $this->config = $config; $this->session = $session; // If there are already messages stored in the current // session, merge them with the provided messages. if ($session->has($this->getSessionKey())) { $messages = array_merge_recursive($session->get($this->getSessionKey()), $messages); } parent::__construct($messages); }
/** * We had the label to display errors right in the bottom * Of the control. * * @param $name * @return null */ public function buildError($name) { $error = null; if ($this->session->has('errors')) { $errors = $this->session->get('errors'); if ($errors->has($name)) { $error = $errors->first($name); } } return $error; }
/** * Captcha check * * @param $value * @return bool */ public function check($value) { if (!$this->session->has('captcha')) { return false; } $key = $this->session->get('captcha.key'); if (!$this->session->get('captcha.sensitive')) { $value = $this->str->lower($value); } $this->session->remove('captcha'); return $this->hasher->check($value, $key); }
/** * Making a charge. * * @param Request $request * @param Order $orderModel * @return \Illuminate\View\View */ public function charge(Request $request, Order $orderModel) { $token = $request->get('stripeToken'); $amount = $request->get('amount'); if ($this->auth->check()) { $this->auth->user()->charge($amount, ['source' => $token]); } else { $this->user->charge($amount, ['source' => $token]); } if (!$this->session->has('cart')) { abort(403, 'There is no cart stored in the session!'); } $cart = $this->session->get('cart'); if ($cart->getTotal() > 0) { $order = $orderModel->create(['user_id' => $this->auth->user()->id, 'total' => $cart->getTotal()]); foreach ($cart->all() as $k => $item) { $order->items()->create(['product_id' => $k, 'price' => $item['price'], 'qty' => $item['qtty']]); } $cart->clear(); return view('ecomm.shop.orders', ['orders' => Auth::user()->orders]); } return view('ecomm.shop.cart', ['cart' => $cart]); }
/** * Create a new view instance. * * @param LaravelFactory $environment * @param \Illuminate\View\Engines\EngineInterface $engine * @param \Illuminate\Translation\Translator $translator * @param string $view * @param string $path * @param array $data * @param Store $session * @return \Jgallred\Simplemessage\View\View */ public function __construct(LaravelFactory $environment, EngineInterface $engine, Translator $translator, $view, $path, $data = array(), Store $session = null) { parent::__construct($environment, $engine, $view, $path, $data); $this->translator = $translator; // If a session driver has been specified, we will bind an instance of the // message container to every view. If a container instance // exists in the session, we will use that instance. if (!isset($this->data[$this->messages_key])) { if ($session && $session->isStarted() and $session->has($this->messages_key)) { $this->data[$this->messages_key] = $session->get($this->messages_key); } else { $this->data[$this->messages_key] = new TypedMessages(); } } }
/** * Retrieve Message instance from Session, the data should be in * serialize, so we need to unserialize it first. * * @return Messages */ public function all($format = null, $display = false) { $format = $this->checkFormat($format); $messages = null; if (!isset($this->instance)) { $this->instance = new static(); $this->instance->setSessionStore($this->session); if ($this->session->has('message')) { $messages = @unserialize($this->session->get('message', '')); } $this->session->forget('message'); if (is_array($messages)) { $this->instance->merge($messages); } } $all = array(); foreach ($this->instance->messages as $key => $messages) { $all = array_merge($all, $this->transform($messages, $format, $key)); } if (!$display) { return $all; } echo implode("\n", $all); }
/** * Called by workerman application<br> * 检验凭证。 参数是凭证数据。如果检验通过,请返回用户ID;否则返回false * @param $credential * @return bool|integer */ public function validateCredential($credential) { list($sessionId, $token) = $credential; $sessionId = \Crypt::decrypt($sessionId); $token = \Crypt::decrypt($token); $sessStore = new Store($sessionId, \App::make('session')->driver()->getHandler(), $sessionId); $sessStore->start(); if ($sessStore->has($this->tokenKey)) { if ($sessStore->get($this->tokenKey) == $token) { $sessStore->remove($this->tokenKey); $userIdKey = 'login_' . md5('Illuminate\\Auth\\Guard'); $userId = $sessStore->get($userIdKey); return $userId; } } return false; }
/** * Twitter constructor. * * @param Config $config * @param SessionStore $session */ public function __construct(Config $config, SessionStore $session) { $this->tconfig = Settings::get('ttwitter'); $client_id = Settings::get('services.twitter.client_id'); $client_secret = Settings::get('services.twitter.client_secret'); $this->tconfig['CONSUMER_KEY'] = isset($client_id) && !empty($client_id) ? $client_id : $this->tconfig['CONSUMER_KEY']; $this->tconfig['CONSUMER_SECRET'] = isset($client_secret) && !empty($client_secret) ? $client_secret : $this->tconfig['CONSUMER_SECRET']; if (empty($this->tconfig)) { throw new Exception('No config found'); } $this->debug = isset($this->tconfig['debug']) && $this->tconfig['debug'] ? true : false; $this->parent_config = ['consumer_key' => $this->tconfig['CONSUMER_KEY'], 'consumer_secret' => $this->tconfig['CONSUMER_SECRET'], 'token' => $this->tconfig['ACCESS_TOKEN'], 'secret' => $this->tconfig['ACCESS_TOKEN_SECRET']]; if ($session->has('access_token')) { $access_token = $session->get('access_token'); if (is_array($access_token) && isset($access_token['oauth_token']) && isset($access_token['oauth_token_secret']) && !empty($access_token['oauth_token']) && !empty($access_token['oauth_token_secret'])) { $this->parent_config['token'] = $access_token['oauth_token']; $this->parent_config['secret'] = $access_token['oauth_token_secret']; } } $this->parent_config['use_ssl'] = $this->tconfig['USE_SSL']; $this->parent_config['user_agent'] = 'LTTW ' . parent::VERSION; parent::__construct($this->parent_config); }
/** * {@inheritdoc} */ public function has($index) { return $this->session->has($index); }
/** * Check if a key exists in the session. * * @param $key * * @return bool */ public function has($key) { return $this->session->has($key); }
/** * Check if a value is set in the session. * * @param string $name * @return mixed */ public function has($name) { return $this->session->has($name); }
function it_can_check_if_the_store_contains_an_item_with_the_given_key(Store $store) { $store->has('my-key.new')->shouldBeCalled(); $this->has('my-key.new')->shouldBeBoolean(); }
/** * Check if an item exists in the session. * * @param $key * @return bool */ public function has($key) { return $this->session->has($this->getSessionKey($key)); }
/** * Checks if an attribute is defined. * * @param string $name The attribute name * @return bool true if the attribute is defined, false otherwise * @static */ public static function has($name) { return \Illuminate\Session\Store::has($name); }
private function session_expires() { if (!$this->session->has(static::SESSION_LAST_ACTIVITY)) { $this->session->set(static::SESSION_LAST_ACTIVITY, time()); return false; } if ($this->timeout > 0 && time() - $this->session->get(static::SESSION_LAST_ACTIVITY, 0) > $this->timeout) { return true; } $this->session->set(static::SESSION_LAST_ACTIVITY, time()); return false; }