protected function makeResponse(Request $request) { $message = $this->translator->get('c::auth.login-required'); if ($request->ajax() || $request->isJson() || $request->wantsJson()) { return Response::json(['error' => $message], 403); } else { $url = $this->url->action('anlutro\\Core\\Web\\AuthController@login'); $intended = $request->getMethod() == 'GET' ? $request->fullUrl() : ($request->header('referer') ?: '/'); $this->session->put('url.intended', $intended); return $this->redirect->to($url)->with('error', $message); } }
/** * Validate what is passed into the age gate * * @param array $data * @return $this|Validation|\Illuminate\Http\RedirectResponse */ public function validate(array $data) { $this->validation = $this->validator->make($data, $this->getValidationRules(), $this->getValidationMessages()); if ($this->validation->fails()) { $failed = $this->validation->failed(); $validExceptTooYoung = array_get($failed, 'dob.Before'); $canTryAgain = config('laravel-avp.can_try_again'); $toRedirect = config('laravel-avp.redirect_on_error'); $redirectURL = config('laravel-avp.redirect_url'); if (substr($data['dob'], 0, 4) > date('Y')) { return redirect()->action('AVPController@agegate')->withErrors($this->validation->messages())->withInput(); } else { if ($validExceptTooYoung && $toRedirect) { return redirect($redirectURL); } else { if ($validExceptTooYoung && !$canTryAgain) { $this->session->put('laravel-avp.previous_too_young', true); } else { $this->session->keep('url.intended'); } } } return redirect()->action('AVPController@agegate')->withErrors($this->validation->messages())->withInput(); } return $this->setCookie($data['remember']); }
/** * Show the cart items. * * @return \Illuminate\View\View */ public function index() { if (!$this->session->has('cart')) { $this->session->put('cart', $this->cart); } $cart = $this->session->get('cart'); return view('ecomm.shop.cart', ['cart' => $cart]); }
public function postValidate() { $validator = $this->validator->make($this->input->all(), array('recaptcha_response_field' => 'required|recaptcha')); if ($validator->fails()) { return $this->response->json(array('result' => 'failed')); } $this->session->put('captcha.passed.time', $this->mockably->microtime()); return $this->response->json(array('result' => 'success')); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $response = $next($request); if ($this->isCacheable($request)) { $uri = $request->getUri(); $this->store->put($this->sessionKey, $uri); } return $response; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!$this->auth->user()->isConfirmed()) { // Don't let people who haven't confirmed their email use the authed sections on the website. $this->session->put('error', 'Please confirm your email address (' . $this->auth->user()->email . ') before you try to use this section. <a style="color:#fff" href="' . route('auth.reconfirm') . '">Re-send confirmation email.</a> <a href="' . route('user.settings', $this->auth->user()->name) . '" style="color:#eee;">Change e-mail address.</a>'); return redirect()->home(); } return $next($request); }
/** * Publish process. * * @param \Orchestra\Contracts\Foundation\Listener\AssetPublishing $listener * @param array $input * * @return mixed */ public function publish(Listener $listener, array $input) { $queues = $this->publisher->queued(); // Make an attempt to connect to service first before try { $this->publisher->connect($input); } catch (ServerException $e) { $this->session->forget('orchestra.ftp'); return $listener->publishingHasFailed(['error' => $e->getMessage()]); } $this->session->put('orchestra.ftp', $input); if ($this->publisher->connected() && !empty($queues)) { $this->publisher->execute(); } return $listener->publishingHasSucceed(); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (config('misc.session_timeout_status')) { $isLoggedIn = $request->path() != '/logout'; if (!session('lastActivityTime')) { $this->session->put('lastActivityTime', time()); } elseif (time() - $this->session->get('lastActivityTime') > $this->timeout) { $this->session->forget('lastActivityTime'); $cookie = cookie('intend', $isLoggedIn ? url()->current() : 'admin/dashboard'); $email = $request->user()->email; access()->logout(); return redirect()->route('frontend.auth.login')->withFlashWarning(trans('strings.backend.general.timeout') . $this->timeout / 60 . trans('strings.backend.general.minutes'))->withInput(compact('email'))->withCookie($cookie); } $isLoggedIn ? $this->session->put('lastActivityTime', time()) : $this->session->forget('lastActivityTime'); } return $next($request); }
/** * @param string $service * @param string $state * @return TokenStorageInterface */ public function storeAuthorizationState($service, $state) { $states = $this->session->get($this->stateVariableName, array()); $states[$service] = $state; $this->session->put($this->stateVariableName, $states); // allow chaining return $this; }
/** * Generate captcha text * * @return string */ protected function generate() { $characters = str_split($this->characters); $bag = ''; for ($i = 0; $i < $this->length; $i++) { $bag .= $characters[rand(0, count($characters) - 1)]; } $this->session->put('captcha', ['sensitive' => $this->sensitive, 'key' => $this->hasher->make($this->sensitive ? $bag : $this->str->lower($bag))]); return $bag; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string $requiredScope * @return mixed * @throws \OAuth2\Exception */ public function handle(Request $request, Closure $next, $requiredScope) { // Ensure this is a valid OAuth client. $accessToken = $this->determineAccessToken($request, false); // check that access token is valid at Poniverse.net $accessTokenInfo = $this->poniverse->getAccessTokenInfo($accessToken); if (!$accessTokenInfo->getIsActive()) { throw new AccessDeniedHttpException('This access token is expired or invalid!'); } if (!in_array($requiredScope, $accessTokenInfo->getScopes())) { throw new AccessDeniedHttpException("This access token lacks the '{$requiredScope}' scope!"); } // Log in as the given user, creating the account if necessary. $this->poniverse->setAccessToken($accessToken); $this->session->put('api_client_id', $accessTokenInfo->getClientId()); $poniverseUser = $this->poniverse->getUser(); $user = User::findOrCreate($poniverseUser['username'], $poniverseUser['display_name'], $poniverseUser['email']); $this->auth->onceUsingId($user); return $next($request); }
/** * Get the access token * * POSTs to the SeeClickFix API and obtains and access key * * @param string $code Code supplied by SeeClickFix * @return string Returns the access token * @throws \SeeClickFix\Core\ApiException */ public function getAccessToken($code) { $token = $this->api->getAccessToken($code); $this->api->setAccessToken($token); $this->user = $this->getCurrentUser(); // Create an array of data to persist to the session $toPersist = array($this->user->getId(), $token); // Set sessions $this->session->put('seeclickfix_access_token', $toPersist); return $token; }
/** * Set the number of rows per page for this data table * * @param \Illuminate\Session\Store $session * @param int $globalPerPage * @param int $override //if provided, this will set the session's rows per page value */ public function setRowsPerPage(\Illuminate\Session\Store $session, $globalPerPage, $override = null) { if ($override) { $perPage = (int) $override; $session->put('administrator_' . $this->config->getOption('name') . '_rows_per_page', $perPage); } $perPage = $session->get('administrator_' . $this->config->getOption('name') . '_rows_per_page'); if (!$perPage) { $perPage = (int) $globalPerPage; } $this->rowsPerPage = $perPage; }
/** * Store the recently viewed tricks in the session. * * @param array $tricks * * @return void */ protected function storeViewedTricks(array $tricks) { $this->session->put('viewed_tricks', $tricks); }
/** * @param \League\OAuth2\Client\Token\AccessToken $accessToken */ protected function updateSession(AccessToken $accessToken) { $this->session->put($this->getSessionName(), $accessToken); }
/** * Store an item in the session * * @param string $name * @param mixed $value * @return mixed */ public function put($name, $value) { return $this->session->put($name, $value); }
/** * Put an item in the session. * * @param $key * @param $value */ public function put($key, $value) { return $this->session->put($this->getSessionKey($key), $value); }
/** * Log the given user ID into the application. * * @param mixed $id * @param bool $remember * @return \Illuminate\Auth\UserInterface */ public function loginUsingId($id, $remember = false) { $this->session->put($this->getName(), $id); return $this->login($this->provider->retrieveById($id), $remember); }
/** * @inheritdoc */ public function set($key, $value) { $this->session->put(static::SESSION_PREFIX . $key, $value); }
/** * @return void */ private function storeCustomClassesInSession() { $this->session->put('classes', $this->customClasses); }
/** * {@inheritDoc} */ public function put($value) { $this->session->put($this->key, $value); }
/** * Put a value in the Sentry session. * * @param mixed $value * @return void */ public function put($value) { $this->session->put($this->getKey(), $value); }
/** * */ public function rememberDesiredUrl() { $desiredUrl = $this->request->fullUrl(); $this->session->put('url.intended', $desiredUrl); }
/** * Close the current form. * * @return string */ public function close() { $this->session->put('formhelper-required-fields', $this->requiredFields); return parent::close(); }
/** * Append the newly viewed trick to the session. * * @param \App\Trick $trick */ protected function storeViewedTrick($trick) { $key = 'viewed_tricks.' . $trick->id; $this->session->put($key, time()); }
/** * Store the recently viewed topics in the session. * * @param array $topics * @return void */ protected function storeViewedTopics(array $topics) { $this->session->put('viewed_topics', $topics); }
/** * Create a new redirect response, while putting the current URL in the session. * * @param string $path * @param int $status * @param array $headers * @param bool $secure * @return \Illuminate\Http\RedirectResponse */ public function guest($path, $status = 302, $headers = [], $secure = null) { $this->session->put('url.intended', $this->generator->full()); return $this->to($path, $status, $headers, $secure); }
/** * {@inheritdoc} */ public function put($index, $value = null) { $this->session->put($index, $value); }
/** * Put a key / value pair or array of key / value pairs in the session. * * @param string|array $key * @param mixed $value * @return void * @static */ public static function put($key, $value = null) { \Illuminate\Session\Store::put($key, $value); }
public function putURL($name, $url = null) { $this->sessionManager->put($this->getName($name), $this->urlOrCurrent($url)); }