Example #1
0
 /**
  * @param \Illuminate\Http\Request $old
  *
  * @return static
  */
 public static function createFromExisting(IlluminateRequest $old)
 {
     $new = new static($old->query->all(), $old->request->all(), $old->attributes->all(), $old->cookies->all(), $old->files->all(), $old->server->all(), $old->content);
     if ($session = $old->getSession()) {
         $new->setSession($old->getSession());
     }
     $new->setRouteResolver($old->getRouteResolver());
     return $new;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function check(Request $request)
 {
     //        $provider = new \League\OAuth2\Client\Provider\GenericProvider([
     //            'clientId' => '1_2jxb8np5n8o4ss0c4wg8csc4sk0oo8gs88s8coc4kgocg44gks',    // The client ID assigned to you by the provider
     //            'clientSecret' => '52gwqoirmm4gs08cscw0wkowwkc8swk4wg0s0wws8gc0w048sc',   // The client password assigned to you by the provider
     //            'redirectUri' => '',
     //            'urlAuthorize' => '',
     //            'urlAccessToken' => 'localhost/SerbinarioCrudRestApi/web/app_dev.php/oauth/v2/token',
     //            'urlResourceOwnerDetails' => ''
     //       ]);
     try {
         $username = $request->input("username");
         $password = $request->input("password");
         // Try to get an access token using the resource owner password credentials grant.
         $accessToken = OauthClientFacade::getAccessToken('password', ['username' => $username, 'password' => $password]);
         $userUri = 'localhost/SerbinarioCrudRestApi/web/app_dev.php/teste';
         $requestOauth = OauthClientFacade::getAuthenticatedRequest('GET', $userUri, $accessToken);
         $user = OauthClientFacade::getResponse($requestOauth);
         $request->session()->set("user", $user);
         $request->session()->set("access_token", $accessToken);
         //$request->getSession()->set("provider_oauth", $provider);
         $request->getSession()->save();
         return redirect()->route('oauth.client.index');
     } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
         // Failed to get the access token
         exit($e->getMessage());
     } catch (\Error $e) {
         exit($e->getMessage());
         return redirect()->route('oauth.client.login');
     }
 }
 /**
  * Checks if a user has attempted to create their account using any OAUTH API's
  * This is useful, so that afterwards we can display the mini form where they can just enter their password
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->getSession()->has('api_user_data')) {
         return $next($request);
     }
     return redirect()->route('login');
 }
 /**
  * Determine if the current request / session has a mismatching "state".
  *
  * @return bool
  */
 protected function hasInvalidState()
 {
     if ($this->isStateless()) {
         return false;
     }
     $state = $this->request->getSession()->pull('state');
     return !(strlen($state) > 0 && $this->request->input('state') === $state);
 }
Example #5
0
 /**
  * Determine if the current request / session has a mismatching "state".
  *
  * @return bool
  */
 protected function hasInvalidState()
 {
     if ($this->isStateless()) {
         return false;
     }
     $session = $this->request->getSession();
     return !($this->request->input('state') === $session->get('state'));
 }
Example #6
0
 /**
  * Get the authenticated user's details.
  *
  * @throws \AltThree\Login\Exceptions\CannotAccessEmailsException
  * @throws \AltThree\Login\Exceptions\InvalidEmailException
  * @throws \AltThree\Login\Exceptions\InvalidStateException
  * @throws \AltThree\Login\Exceptions\IsBlacklistedException
  * @throws \AltThree\Login\Exceptions\NoEmailException
  * @throws \AltThree\Login\Exceptions\NotWhitelistedException
  *
  * @return string[]
  */
 public function user()
 {
     $state = $this->request->getSession()->pull('state');
     if (strlen($state) !== 40 || $this->request->input('state') !== $state) {
         throw new InvalidStateException('We could not verify the request was genuine.');
     }
     $token = $this->getAccessToken($this->request->input('code'));
     return $this->getUserByToken($token);
 }
Example #7
0
 /**
  * @param Request $request
  * @param Closure $next
  *
  * @return \Illuminate\Http\Response
  */
 public function handle(Request $request, Closure $next)
 {
     $session = $request->getSession();
     $this->preRequestHandle($session, $request);
     $response = $next($request);
     $session = $request->getSession();
     $this->postRequestHandle($session, $response);
     return $response;
 }
Example #8
0
 public function callback(Request $request)
 {
     $order = Order::with('payment')->where('sn', '=', $request->get('sn'))->firstOrFail();
     $response = $order->payment->gateway->complete($order->createPurchaseOrder());
     if ($order->payment->gateway->isSuccessful($response)) {
         $order->pay($order->total_amount);
         return redirect($request->getSession()->pull('payment_callback_redirect'));
     } else {
         throw new \Exception($response->getMessage());
     }
 }
Example #9
0
 /**
  * Initialize the form request with data from the given request.
  *
  * @param  Request  $request
  * @return void
  */
 public function setRequest(Request $request)
 {
     $files = $request->files->all();
     $files = is_array($files) ? array_filter($files) : $files;
     $this->initialize($request->query->all(), $request->request->all(), $request->attributes->all(), $request->cookies->all(), $files, $request->server->all(), $request->getContent());
     if ($session = $request->getSession()) {
         $this->setSession($session);
     }
     $this->setUserResolver($request->getUserResolver());
     $this->setRouteResolver($request->getRouteResolver());
 }
Example #10
0
 public function postUpload(Request $request)
 {
     $file = $request->file('file');
     $token = $request->getSession()->get('access_token');
     if ($file->isValid()) {
         $uploadedFile = $this->imageRepository->create($file, $request->user());
         $this->dispatch(new PerformOcr($uploadedFile, $token));
         return json_encode(['status' => 'success']);
     }
     return json_encode(['status' => 'failed']);
 }
Example #11
0
 public function decorate(Request $current)
 {
     $files = $current->files->all();
     $files = is_array($files) ? array_filter($files) : $files;
     $this->initialize($current->query->all(), $current->request->all(), $current->attributes->all(), $current->cookies->all(), $files, $current->server->all(), $current->getContent());
     if ($session = $current->getSession()) {
         $this->setSession($session);
     }
     $this->setUserResolver($current->getUserResolver());
     $this->setRouteResolver($current->getRouteResolver());
     $this->originalRequest = $current;
 }
Example #12
0
 public function callback(Request $request, $provider)
 {
     $openid = Socialite::with($provider)->user();
     User::bind($openid, $provider);
     $url = parse_url($request->getSession()->pull('auth_redirect'));
     $url['query'] = ($url['query'] ? '&' : '') . "email={$openid->email}&token={$openid->token}";
     return redirect("{$url['scheme']}://{$url['host']}{$url['path']}?{$url['query']}");
     // return redirect(, [
     //     'email'=>$openid->getEmail(),
     //     'token'=>$openid->token
     // ], HTTP_URL_JOIN_QUERY));
 }
 /**
  * @param \Coyote\Forum $forum
  * @param Request $request
  * @return $this
  */
 public function index($forum, Request $request)
 {
     // builds breadcrumb for this category
     $this->breadcrumb($forum);
     // create view with online users
     $viewers = app()->make('Session\\Viewers')->render($request->getRequestUri());
     $this->pushForumCriteria();
     $forumList = $this->forum->forumList();
     $this->topic->pushCriteria(new BelongsToForum($forum->id));
     $topics = $this->topic->paginate(auth()->id(), $request->getSession()->getId());
     // let's cache tags. we don't need to run this query every time
     $tags = Cache::remember('forum:tags', 60 * 24, function () {
         return $this->forum->getTagClouds();
     });
     return parent::view('forum.category')->with(compact('viewers', 'forumList', 'forum', 'topics', 'tags'));
 }
 public function postListing(Request $request)
 {
     $data = $request->all();
     // Create listing
     $listing = \App\Listing::create(['address1' => $data['address1'], 'address2' => $data['address2'], 'city' => $data['city'], 'state' => $data['state'], 'zip' => $data['zip'], 'property_type' => $data['property_type'], 'condition' => $data['condition'], 'beds' => $data['beds'], 'baths' => $data['baths'], 'additional_rooms' => $data['additional_rooms'], 'approx_size' => $data['approx_size'], 'approx_age_of_kitchen' => $data['approx_age_of_kitchen'], 'approx_age_of_baths' => $data['approx_age_of_baths'], 'message' => $data['message'], 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'email' => $data['email'], 'phone' => $data['phone']]);
     $userData = $this->mapData($data);
     $checkForUser = \App\User::where('email', '=', $userData['email'])->first();
     if (is_null($checkForUser)) {
         // Create User
         $user = \App\User::create(['name' => $userData['name'], 'email' => $userData['email'], 'password' => bcrypt($userData['password']), 'phone' => $userData['phone']]);
     }
     $email = 'emails.listingPost';
     $data['name'] = $userData['name'];
     $this->mailIt($email, $data);
     dd($request->getSession());
     return redirect()->back()->with('success_message', 'Your listing has been sent for review...');
 }
Example #15
0
 /**
  * Get the token credentials for the request.
  *
  * @return \League\OAuth1\Client\Credentials\TokenCredentials
  */
 protected function getToken()
 {
     $temp = $this->request->getSession()->get('oauth.temp');
     return $this->server->getTokenCredentials($temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier'));
 }
 private function performLocalRequest(Request $parentRequest = null, $url, $method, $data, &$statusCode = null)
 {
     $urlInfo = parse_url($url);
     if (array_key_exists('query', $urlInfo) == true && mb_strlen($urlInfo['query']) > 0) {
         mb_parse_str($urlInfo['query'], $_GET);
     }
     // create the request object
     $cookies = $parentRequest ? $parentRequest->cookies->all() : [];
     $server = $parentRequest ? $parentRequest->server->all() : [];
     $request = Request::createFromBase(SymfonyRequest::create($url, $method, [], $cookies, [], $server, json_encode($data)));
     $request->headers->set('Content-Type', 'application/json');
     if ($parentRequest !== null) {
         $locale = $parentRequest->getLocale();
         $request->setSession($parentRequest->getSession());
         $request->setLocale($locale);
         $request->headers->set('Accept-Language', [$locale]);
     }
     // execute the request
     // TODO: handle errors gracefully
     $kernel = $GLOBALS['kernel'];
     //$this->app->make(\Illuminate\Contracts\Http\Kernel::class);
     $response = $kernel->handle($request, HttpKernelInterface::SUB_REQUEST);
     $statusCode = $response->getStatusCode();
     $content = $response->getContent();
     return $content;
 }
Example #17
0
 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @param  \Illuminate\Http\Request  $request
  * @return void
  *
  * @throws \Illuminate\Session\TokenMismatchException
  */
 public function filter(Route $route, Request $request)
 {
     if ($request->getSession()->token() != $request->input('_token')) {
         throw new TokenMismatchException();
     }
 }
 /**
  * Permanently destroys a user's account
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function destroy(Request $request)
 {
     if ($request->getSession()->has('password.confirmed' . h($request->user()->id))) {
         $this->data = $this->accounts->deleteAccount(true);
         return $this->handleRedirect($request, route('home'));
     }
     flash()->error('You need to confirm your password first');
     return redirect()->back();
 }
 /**
  * Displays the account creation form for a guest user
  *
  * @return \Illuminate\View\View
  */
 public function getCreateAccount(Request $request)
 {
     // save target url in session
     $request->getSession()->set('after_account_create', $request->get('proceedTo'));
     // check if a usr has done previous steps
     // ------
     return view('frontend.checkout.create_account');
 }
Example #20
0
 /**
  * Set the user locale.
  *
  * @param string  $locale
  * @param Request $request
  */
 protected function setUserLocale($locale, $request)
 {
     $request->getSession()->put(['locale' => $locale]);
     $request->getSession()->reflash();
 }
 /**
  * Display the mini form that users will fill in prior to registration via an API
  *
  * @param Request $request
  * @return \Illuminate\View\View
  */
 public function getMiniRegistrationForm(Request $request)
 {
     $user = $request->getSession()->get('api_user_data');
     return view('auth.fillRemaining', compact('user'));
 }
 /**
  * Creates a user's account using OAUTH provider API data
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function createAccount(Request $request)
 {
     $user = $this->userRepository->createUserUsingDataFromAPI($request->getSession()->get('api_user_data'), $request->all());
     $this->auth->login($user, true);
     // update the last logged in field
     $this->updateLastLogin();
     $this->session->pull('api_user_data');
     return redirect()->intended(session('url.intended', '/'));
 }
Example #23
0
 /**
  * Determine if the current request / session has a mismatching "state".
  *
  * @return bool
  */
 protected function hasInvalidState()
 {
     $session = $this->request->getSession();
     return !($this->request->input('state') === $session->get('state'));
 }
Example #24
0
 /**
  * Gets the Session.
  *
  * @return \Symfony\Component\HttpFoundation\SessionInterface|null The session
  * @static 
  */
 public static function getSession()
 {
     //Method inherited from \Symfony\Component\HttpFoundation\Request
     return \Illuminate\Http\Request::getSession();
 }
 /**
  * Get the session data.
  *
  * @return array
  */
 public function getSession()
 {
     $session = $this->request->getSession();
     return $session ? $session->all() : [];
 }