/**
  * {@inheritdoc}
  *
  * @see BaseFacebook::setPersistentData()
  */
 protected function setPersistentData($key, $value)
 {
     if (!in_array($key, self::$kSupportedKeys)) {
         self::errorLog('Unsupported key passed to setPersistentData.');
         return;
     }
     $session_var_name = $this->constructSessionVariableName($key);
     $this->laravelSession->put($session_var_name, $value);
 }
Esempio n. 2
0
 /**
  * Sets the app locale
  *
  * @param string $locale
  * @param bool $session
  * @return void
  */
 public function setAppLocale($locale = null, $session = true)
 {
     $locale = $locale ?: $this->session->get('_locale', null);
     if ($locale) {
         $this->app->setLocale($locale);
         if ($session) {
             $this->session->put('_locale', $locale);
         }
         $this->setTimeLocale($locale);
     }
 }
 /**
  * POST method for switching a user's locale
  *
  * @param string	$locale
  *
  * @return JSON
  */
 public function switchLocale($locale)
 {
     if (in_array($locale, config('administrator.locales'))) {
         $this->session->put('administrator_locale', $locale);
     }
     return redirect()->back();
 }
Esempio n. 4
0
 /**
  * POST method for handling custom actions on the settings page.
  *
  * @param string $settingsName
  *
  * @return JSON
  */
 public function settingsCustomAction($settingsName)
 {
     $config = app('itemconfig');
     $actionFactory = app('admin_action_factory');
     $actionName = $this->request->input('action_name', false);
     //get the action and perform the custom action
     $action = $actionFactory->getByName($actionName);
     $data = $config->getDataModel();
     $result = $action->perform($data);
     //override the config options so that we can get the latest
     app('admin_config_factory')->updateConfigOptions();
     //if the result is a string, return that as an error.
     if (is_string($result)) {
         return response()->json(array('success' => false, 'error' => $result));
     } elseif (!$result) {
         $messages = $action->getOption('messages');
         return response()->json(array('success' => false, 'error' => $messages['error']));
     } else {
         $response = array('success' => true, 'actions' => $actionFactory->getActionsOptions(true));
         //if it's a download response, flash the response to the session and return the download link
         if (is_a($result, 'Symfony\\Component\\HttpFoundation\\BinaryFileResponse')) {
             $file = $result->getFile()->getRealPath();
             $headers = $result->headers->all();
             $this->session->put('administrator_download_response', array('file' => $file, 'headers' => $headers));
             $response['download'] = route('admin_file_download');
         } elseif (is_a($result, '\\Illuminate\\Http\\RedirectResponse')) {
             $response['redirect'] = $result->getTargetUrl();
         }
         return response()->json($response);
     }
 }
Esempio n. 5
0
 /**
  * Create captcha image
  * @param null $formId
  */
 public function create($formId = null)
 {
     //Generate formId
     if (empty($formId)) {
         //$formId = $this->fromPreviousUrl();
         $formId = $this->fromAppKey();
     }
     //Generate random string
     $string = $this->randomString($this->config->get('captcha.length'), $this->config->get('captcha.letters') && $this->config->get('captcha.numbers') ? 1 : ($this->config->get('captcha.letters') ? 2 : 3), $this->config->get('captcha.case') == 'upper' ? 2 : ($this->config->get('captcha.case') == 'lower' ? 3 : 1));
     //Store in session
     $this->session->put("{$this->storeKey}.{$formId}", $this->hash($this->config->get('captcha.case_sensitive') ? $string : strtolower($string)));
     //Colors
     $colors = $this->config->get('captcha.colors');
     $background = $this->config->get('captcha.background');
     $line = $this->config->get('captcha.line_color');
     //Create image
     $image = imagecreatetruecolor($this->config->get('captcha.width'), $this->config->get('captcha.height'));
     //Colors
     $background = imagecolorallocate($image, $background[0], $background[1], $background[2]);
     $line = imagecolorallocate($image, $line[0], $line[1], $line[2]);
     //Background
     imagefilledrectangle($image, 0, 0, $this->config->get('captcha.width'), $this->config->get('captcha.height'), $background);
     //Background Horizontal lines
     for ($i = 1; $i < $this->config->get('captcha.h_lines'); $i++) {
         imageline($image, 0, $this->config->get('captcha.height') / $this->config->get('captcha.h_lines') * $i, $this->config->get('captcha.width'), $this->config->get('captcha.height') / $this->config->get('captcha.h_lines') * $i, $line);
     }
     //Background Vertical lines
     for ($i = 1; $i < $this->config->get('captcha.v_lines'); $i++) {
         imageline($image, $this->config->get('captcha.width') / $this->config->get('captcha.v_lines') * $i, 0, $this->config->get('captcha.width') / $this->config->get('captcha.v_lines') * $i, $this->config->get('captcha.height'), $line);
     }
     //Text
     for ($i = 0; $i < $this->config->get('captcha.length'); $i++) {
         $color = $colors[rand(0, count($colors) - 1)];
         imagettftext($image, $this->config->get('captcha.size'), rand(-$this->config->get('captcha.angle'), $this->config->get('captcha.angle')), 10 + $i * $this->config->get('captcha.separation'), $this->config->get('captcha.size') + 10, imagecolorallocate($image, $color[0], $color[1], $color[2]), $this->font, substr($string, $i, 1));
     }
     //Stream
     header('Content-Type: image/jpeg');
     header('Cache-Control: no-cache, no-store, must-revalidate');
     imagejpeg($image, null, $this->config->get('captcha.quality'));
     imagedestroy($image);
 }
Esempio n. 6
0
 public function getAuthLink(SessionManager $session, Manager $auth, $provider)
 {
     $user = Socialite::driver($provider)->user();
     $dbUser = $auth->user();
     $link = SocialConnection::ofCredentials($provider, $user->id)->first();
     $linked = !is_null($link);
     $authenticated = !is_null($dbUser);
     // Link: Authenticated not linked
     if ($authenticated && !$linked) {
         // Link
         $dbUser->attachProvider($provider, $user);
         return redirect('/')->with('success', 'Account connected to "' . $provider . '" successfully.');
     } elseif (!$authenticated && $linked) {
         // Log in user
         $dbUser = $auth->login($link->user_id);
         return redirect('/')->with('success', 'Authentication with "' . $provider . '" was successful');
     } else {
         // Store to connect accounts after login
         $session->put('social_link', ['user' => $user, 'provider' => $provider]);
         // No user found - redirect to login
         return redirect('login')->with('error', 'No matching records found, please login to link accounts.');
     }
 }
Esempio n. 7
0
 /**
  * Sync the cart to session.
  *
  * @param \Illuminate\Support\Collection|null $cart The new cart content
  *
  * @return \Illuminate\Support\Collection
  */
 protected function save($cart)
 {
     $this->session->put($this->name, $cart);
     return $cart;
 }
Esempio n. 8
0
 /**
  * 인증 세션 생성
  *
  * @param ItemEntity $item board item entity
  * @return void
  */
 public function create(ItemEntity $item)
 {
     $this->session->put($this->getKey($item->id), ['certifyKey' => $item->certifyKey, 'expire' => $this->expireTime()]);
 }
Esempio n. 9
0
 /**
  * Update the cart
  *
  * @param  \Illuminate\Support\Collection|null  $cart  The new cart content
  * @return \Illuminate\Support\Collection
  */
 protected function updateCart($cart)
 {
     return $this->session->put($this->getInstance(), $cart);
 }
Esempio n. 10
0
 /**
  * Sets a key-value pair in storage.
  *
  * @param string $key   The key to set
  * @param mixed  $value The value to set
  *
  * @return null
  */
 public function set($key, $value)
 {
     $this->session->put($this->storageKey . '.' . $key, $value);
     return null;
 }
Esempio n. 11
0
 protected function saveMessage($message)
 {
     $this->session->put('message', $message);
     //     	$this->message = $message;
 }
Esempio n. 12
0
 /**
  * {@inheritDoc}
  */
 public function storeAccessToken($service, TokenInterface $token)
 {
     $name = $this->storageName($service);
     $this->session->put($name, serialize($token));
     return $this;
 }
 /**
  * 인증 세션 생성
  *
  * @param Board $board board model
  * @return void
  */
 public function create(Board $board)
 {
     $this->session->put($this->getKey($board->id), ['certifyKey' => $board->certifyKey, 'expire' => $this->expireTime()]);
 }