Get the session implementation from the manager.

@param  \Illuminate\Http\Request $request

@return \Illuminate\Contracts\Session\Session
8633
public function getSession(Request $request)
    {
        return tap($this->manager->driver(), function (Session $session) use ($request) {
            $session->setId($request->cookies->get($session->getName()));
        });
    }
1137860
public function login(Request $request)
  {
    $hidden = $this->hidden;
    $request->rules = $this->rules();
    $provider = $this->provider;

    $user = $request->validate(function($response) use ($request, $hidden, $provider) {
      return Auth::attempt($request->all(), $hidden, $provider);
    });

    if (Auth::provider($provider)->login($user)->status == 'success') {
      Redirect::to($this->redirectPath(), 200);
    }
  }
1320258
public function getLogin(Request $request)
    {
        $user = $this->getUser();
        if ($user && $user->getEnabled() == 1) {
            $response = $this->redirectToRoute('dashboard');

            $token = $this->session()->get('authentication');
            $this->setAuthenticationCookie($request, $response, $token);

            return $response;
        }

        if ($this->getOption('general/enforce_ssl') && !$request->isSecure()) {
            return $this->redirect(preg_replace('/^http:/i', 'https:', $request->getUri()));
        }

        $userEntity = new Entity\Users();
        // Generate the form
        $form = $this->createFormBuilder(FormType\UserLoginType::class, $userEntity)
            ->getForm()
            ->handleRequest($request)
        ;
        /** @var Form $form */
        if ($form->isSubmitted() && $form->isValid()) {
            $action = $form->getClickedButton()->getName();
            if ($action === 'login') {
                $response = $this->handlePostLogin($request, $form);
            } elseif ($action === 'reset') {
                $response = $this->handlePostReset($request, $form);
            } else {
                // Let's not disclose any internal information.
                throw new HttpException(Response::HTTP_BAD_REQUEST, 'Invalid request');
            }
            if ($response instanceof Response) {
                return $response;
            }
        }
        $context = [
            'form'        => $form->createView(),
            'randomquote' => true,
        ];

        return $this->render('@bolt/login/login.twig', $context);
    }
1175086
public function postLogin(Request $request)
    {
        // Validate the Form Data
        $result = $this->validate($request, [
            'email' => 'required',
            'password' => 'required'
        ]);

        // Assemble Login Credentials
        $credentials = [
            'email' => trim($request->get('email')),
            'password' => $request->get('password'),
        ];
        $remember = (bool)$request->get('remember', false);

        // Attempt the Login
        $result = $this->authManager->authenticate($credentials, $remember);

        // Return the appropriate response
        $path = session()->pull('url.intended', route('dashboard'));
        return $result->dispatch($path);
    }
696284
public function createAction(Request $request)
    {
        if ($this->get('session')->has('module')) {
            // get the last module from the session to fill some defaults for the new one
            $tmpModule = $this->get('session')->get('module');

            // setup a fresh module object
            $module = new Module();
            $module->setStyle($tmpModule->getStyle());
        }
        else {
            // setup a fresh module object
            $module = new Module();

            // fill it with some defaults
            $module->setStyle('less');
        }

        // create form
        $form = $this->createForm(new ModuleType(), $module);

        if ($request->getMethod() == 'POST') {
            $form->bindRequest($request);

            if ($form->isValid()) {
                // set default templates
                $module->addTemplate(strtolower($module->getName()));

                // save the module in the session
                $this->get('session')->set('module', $module);

                // create the module in the filesystem
                try {
                    $moduleManager = $this->get('terrific.composer.module.manager');
                    $moduleManager->createModule($module);

                    $this->get('session')->setFlash('notice', 'Module ' . ucfirst($module->getName()) . ' created successfully');
                }
                catch (\Exception $e) {
                    $logger = $this->get('logger');
                    $logger->err($e->getMessage());

                    $this->get('session')->setFlash('notice', 'Module could not be created: ' . $e->getMessage());
                }

                if ($request->get('addskin', false)) {
                    // redirect to the add skin form
                    return $this->redirect($this->generateUrl('composer_add_skin'));
                }
                else {
                    // redirect to the create module form
                    return $this->redirect($this->generateUrl('composer_create_module'));
                }
            }
        }

        return array('form' => $form->createView());
    }
862478
private function getManagerForRequest(Request $request)
    {
        if (!$request->getManager()) {
            $request->setManager($this->managerList->get());
        }

        return $request->getManager();
    }
487415
public function user(Request $request)
    {
        if ($request->bearerToken()) {
            return $this->authenticateViaBearerToken($request);
        } elseif ($request->cookie(Passport::cookie())) {
            return $this->authenticateViaCookie($request);
        }
    }
302394
public function authenticate(Request $request)
    {
        if ($request->hasSession()) {
            $request->session()->reflash();
        }

        return Broadcast::auth($request);
    }
1338647
public function sessionAction(Request $request)
    {
        $output = '<pre>';
        $output .= 'Security session namespace:'.PHP_EOL;
        $output .= '<ul>';
        foreach ($request->getSession()->all() as $key => $value) {
            if (is_object($value)) {
                $o = get_class($value);
            } elseif (is_array($value)) {
                $o = 'array '.count($value);
            } else {
                $o = $value;
                if (@unserialize($o)) {
                    $o = unserialize($o);
                }
            }
            $output .= '<li>'.$key.': '.$o.'</li>';
        }
        $output .= '</ul>';

        return new Response($output);
    }
494993
public function loginAction(Request $request)
    {
        if ($this->getUser() instanceof UserInterface) {
            $this->addFlash('sonata_user_error', 'sonata_user_already_authenticated');
            $url = $this->generateUrl('sonata_admin_dashboard');

            return $this->redirect($url);
        }

        $session = $request->getSession();

        $authErrorKey = Security::AUTHENTICATION_ERROR;

        // get the error if any (works with forward and redirect -- see below)
        if ($request->attributes->has($authErrorKey)) {
            $error = $request->attributes->get($authErrorKey);
        } elseif (null !== $session && $session->has($authErrorKey)) {
            $error = $session->get($authErrorKey);
            $session->remove($authErrorKey);
        } else {
            $error = null;
        }

        if (!$error instanceof AuthenticationException) {
            $error = null; // The value does not come from the security component.
        }

        if ($this->isGranted('ROLE_ADMIN')) {
            $refererUri = $request->server->get('HTTP_REFERER');

            return $this->redirect($refererUri && $refererUri != $request->getUri() ? $refererUri : $this->generateUrl('sonata_admin_dashboard'));
        }

        $csrfToken = $this->has('security.csrf.token_manager')
            ? $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue()
            : null;

        return $this->render('NetworkingInitCmsBundle:Admin:Security/login.html.twig', [
            'admin_pool' => $this->get('sonata.admin.pool'),
            'base_template' => $this->get('sonata.admin.pool')->getTemplate('layout'),
            'csrf_token' => $csrfToken,
            'error' => $error,
            'last_username' => (null === $session) ? '' : $session->get(Security::LAST_USERNAME),
            'reset_route' => $this->generateUrl('networking_init_cms_admin_resetting_request'),
        ]);
    }
201558
public function setRequest(Request $request)
    {
        $context = (new RequestContext())->fromRequest($request);

        $this->cachedRoot = null;
        $this->cachedSchema = null;
        return $this->setContext($context);
    }
420344
public function loginAction(Request $request): Response
    {
        $session = $request->getSession();

        # https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/Resources/doc/a_note_about_security.md
        if ($request->attributes->has('_fos_oauth_server_authorize_enabled') && $session->has('_security.target_path')) {
            if (false !== strpos($session->get('_security.target_path'), $this->router->generate('fos_oauth_server_authorize'))) {
                $session->set('_fos_oauth_server.ensure_logout', true);
            }
        }

        $alreadyLoggedInRedirectRoute = $request->attributes->get('_sylius')['logged_in_route'] ?? null;

        if ($alreadyLoggedInRedirectRoute && $this->authorizationChecker->isGranted('IS_AUTHENTICATED_FULLY')) {
            return new RedirectResponse($this->router->generate($alreadyLoggedInRedirectRoute));
        }

        $lastError = $this->authenticationUtils->getLastAuthenticationError();
        $lastUsername = $this->authenticationUtils->getLastUsername();
        $options = $request->attributes->get('_sylius');
        $template = $options['template'] ?? '@chang/security/login.html.twig';
        $formType = $options['form'] ?? SecurityLoginType::class;
        $form = $this->formFactory->createNamed('', $formType);

        return $this->templateEngine->renderResponse($template, [
            'form' => $form->createView(),
            'last_username' => $lastUsername,
            'last_error' => $lastError,
            'login_check_route' => $request->attributes->get('_sylius')['login_check_route'] ?? null,
            'csrf_parameter' => $request->attributes->get('_sylius')['csrf_parameter'] ?? null,
            'csrf_token_id' => $request->attributes->get('_sylius')['csrf_token_id'] ?? null,
        ]);
    }
439006
public function targetGroupAction(Request $request)
    {
        $currentTargetGroup = null;
        if ($request->headers->has($this->targetGroupHeader)) {
            $currentTargetGroup = $this->targetGroupRepository->find($request->headers->get($this->targetGroupHeader));
        }

        $targetGroup = $this->targetGroupEvaluator->evaluate(
            $currentTargetGroup ? TargetGroupRuleInterface::FREQUENCY_SESSION : TargetGroupRuleInterface::FREQUENCY_VISITOR,
            $currentTargetGroup
        );

        $response = new Response(null, 200, [
            $this->targetGroupHeader => $targetGroup ? $targetGroup->getId() : 0,
        ]);

        return $response;
    }
1202602
public function removeSessionAction(Request $request)
    {
        /** @var \Doctrine\Common\Persistence\ObjectManager $om */
        $om = $this->get($this->container->getParameter('ma27_api_key_authentication.object_manager'));

        if (!$header = (string) $request->headers->get($this->container->getParameter('ma27_api_key_authentication.key_header'))) {
            return new JsonResponse(['message' => 'Missing api key header!'], 400);
        }

        $user = $om
            ->getRepository($this->container->getParameter('ma27_api_key_authentication.model_name'))
            ->findOneBy([
                $this->getPropertyName(ClassMetadata::API_KEY_PROPERTY) => $header,
            ]);

        $this->get('ma27_api_key_authentication.auth_handler')->removeSession($user);

        return new JsonResponse([], 204);
    }
1000129
public function fromRequest(Request $request)
    {
        $this->setBaseUrl($request->getBaseUrl());
        $this->setPathInfo($request->getPathInfo());
        $this->setMethod($request->getMethod());
        $this->setHost($request->getHost());
        $this->setScheme($request->getScheme());
        $this->setHttpPort($request->isSecure() ? $this->httpPort : $request->getPort());
        $this->setHttpsPort($request->isSecure() ? $request->getPort() : $this->httpsPort);
        $this->setQueryString($request->server->get('QUERY_STRING', ''));

        return $this;
    }
991924
public function login(Request $request)
    {
        $this->validateLogin($request);

        // If the class is using the ThrottlesLogins trait, we can automatically throttle
        // the login attempts for this application. We'll key this by the username and
        // the IP address of the client making these requests into this application.
        if ($lockedOut = $this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);

            return $this->sendLockoutResponse($request);
        }

        $credentials = $this->credentials($request);

        if ($this->guard()->attempt($credentials, $request->has('remember'))) {
            return $this->sendLoginResponse($request);
        }

        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.
        if (! $lockedOut) {
            $this->incrementLoginAttempts($request);
        }

        return $this->sendFailedLoginResponse($request);
    }
663536
public function execute(RequestInterface $request): RequestInterface
    {
        if (is_null($this->sessionToken)) {
            return $request;
        } else {
            return $request->withHeader(
                self::HEADER_CLIENT_AUTHENTICATION,
                [$this->sessionToken->getToken()]
            );
        }
    }