Perform the login into LinkedIn

@param Request $request
@return \Symfony\Component\HttpFoundation\Response
@throws \Exception
540303
public function loginAction(Request $request)
    {
        $oauth = $this->get('campaignchain.security.authentication.client.oauth.authentication');
        $oauth->authenticate(self::RESOURCE_OWNER, $this->applicationInfo, true);
        $wizard = $this->get('campaignchain.core.channel.wizard');
        $wizard->set('profile', $oauth->getProfile());

        // Allow to easily find the Facebook user's ID through the Wizard.
        $wizard->set('linkedin_user_id', $oauth->getProfile()->identifier);
        $tokens[$oauth->getProfile()->identifier] = $oauth->getToken();
        $wizard->set('tokens', $tokens);
        return $this->render('CampaignChainChannelLinkedInBundle:Create:closePopUp.html.twig');
    }
989008
public function postLogin(Request $request)
    {
        $this->validate($request, [
            'user'      => 'required',
            'password'  => 'required',
        ]);

        $credentials = $request->only('user', 'password');

        if(auth()->guard('pulsar')->attempt($credentials, $request->has('remember')))
        {
            // check if user has access
            if(!auth()->guard('pulsar')->user()->access_010)
            {
                auth()->guard('pulsar')->logout();
                return redirect($this->loginPath)
                    ->withInput($request->only('user', 'remember'))
                    ->withErrors([
                        'loginErrors' => 3
                    ]);
            }

            // set user access control list
            session(['userAcl' => AclLibrary::getProfileAcl(auth()->guard('pulsar')->user()->profile_id_010)]);

            // check if user has permission to access
            if (!is_allowed('pulsar', 'access'))
            {
                auth()->guard('pulsar')->logout();
                return redirect($this->loginPath)
                    ->withInput($request->only('user', 'remember'))
                    ->withErrors([
                        'loginErrors' => 2
                    ]);
            }

            session(['packages' => Package::getRecords(['active_012' => true, 'orderBy' => ['column' => 'sorting_012', 'order' => 'desc']])]);
            session(['baseLang' => Lang::getBaseLang()]);

            return redirect()->intended($this->redirectTo);
        }

        return redirect($this->loginPath)
            ->withInput($request->only('user', 'remember'))
            ->withErrors([
                'loginErrors' => 1
            ]);
    }
1156183
protected function sendFailedLoginResponse(Request $request)
    {
        return redirect()->back()
            ->withInput($request->only($this->username(), 'remember'))
            ->withErrors([
                $this->username() => Lang::get('auth.failed'),
            ]);
    }
641174
private function attemptAuthentication(Request $request)
    {
        return $this->authenticationManager->authenticate(
            new UsernamePasswordToken(
                $request->attributes->get('username'),
                $request->attributes->get('password'),
                $this->providerKey
            )
        );
    }
161700
protected function sendFailedLoginResponse(Request $request)
    {
        $credentials = $this->credentials($request);

        $user = User::where('email', $credentials['email'])->first();
        if (!$user) {
            $error = __('This user was not found.');
        } elseif (!$user->activated) {
            $error = __('This user is not activated.');
        } else {
            $error = __('The password is incorrect.');
        }

        $errors = [$this->username() => $error];

        if ($request->expectsJson()) {
            return response()->json($errors, 422);
        }

        return redirect()->back()
            ->withInput($request->only($this->username(), 'remember'))
            ->withErrors($errors);
    }
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);
    }
1142361
private function login(Request $request)
    {
        $user = $this->loginProvider->authenticate($request);
        if (null !== $user) {
            try {
                $token = $user->createToken($this->tokenSalt);
                $this->tokenStore->store($request, $token, $user);
                return $user;
            } catch (\Exception $e) {
                throw new InternalAuthProviderException(
                        'Error while trying to store new token for user: ' . $e->getMessage(),
                        $e
                );
            }
        }

        return null;
    }
628289
public function postLogin(Request $request)
    {
        $credentials = $request->only(['mobile', 'password']);

        $validator = Validator::make($credentials, [
            'mobile' => 'required', 'password' => 'required',
        ]);

        if ($validator->fails()) {
            return Redirect::back()->withInput()->withErrors($validator);
        }

        if (Auth::guard('merchant')->attempt($credentials)) {
            merchant_toastr(trans('merchant.login_successful'));

            return redirect()->intended(config('merchant.route.prefix'));
        }

        return Redirect::back()->withInput()->withErrors(['mobile' => $this->getFailedLoginMessage()]);
    }
322843
public function handleAuth(Request $request)
    {
        try {
            $user = Socialite::with('github')->stateless()->user();
        } catch (Exception $e) {
            return redirect('/dash-login');
        }

        $request->session()->put(
            config('pagekit.session_key', 'pagekit_session'), [
            'github_id' => $user->id,
            'github_name' => $user->name,
            'github_email' => $user->email
            ]
        );
            $request->session()->save();
            return $user->user['login'];

    }
724425
public function run(Request $request) {
		$prefs = $this->getServiceContainer()->getPreferenceLoader()->getSystemPreferences();
		$routes = $this->generateRoutes();
		$response = new Response();
		$context = new RequestContext($prefs->getAccountUrl());
		$matcher = new UrlMatcher($routes, $context);
		$payload = [];

		$match = $matcher->match($this->getDestination());
		$route = $match['_route'];
		$module = $this->getModule();
		$auth = $this->getServiceContainer()->getAuthManager();
		$action = null;

		switch ($route) {
			case 'index':
				if ($auth->isRecognized()) {
					$action = $module->loadAction('dashboard', 'html');
				} else {
					$action = $module->loadAction('index', 'html');
				}
				break;

			case 'register':
				$action = $module->loadAction('register', 'html');
				break;

			case 'forgot-password':
			case 'forgot-password-token':
				$action = $module->loadAction('forgot-password', 'html');
				$action->setParams([
					'token' => isset($match['token']) ? $match['token'] : null
				]);
				break;

			case 'login':
				$action = $module->loadAction('login', 'html');
				break;

			case 'activity':
				$action = $module->loadAction('activity', 'html');
				break;

			case 'settings':
				$action = $module->loadAction('settings', 'html');
				$action->setParams([
					'section' => $match['section']
				]);
				break;

			case 'logout':
				$action = $module->loadAction('logout');
				break;
		}

		$kernel = $this->getServiceContainer()->getKernel();
		$response = $kernel->handle($action, $request);

		if ($response instanceof RedirectResponse) {
			return $response;
		}

		$payload = [
			'main' => $response->getContent(),
		];

		return $this->responder->run($request, new Blank($payload));
	}
581556
public function entryAction(Request $request)
    {
        $language = $this->getLanguage($request);
        $webspace = $this->getWebspace($request);

        $depth = $this->getRequestParameter($request, 'depth', false, 1);
        $ghostContent = $this->getBooleanRequestParameter($request, 'ghost-content', false, false);

        $view = $this->responseGetById(
            null,
            function() use ($language, $webspace, $depth, $ghostContent) {
                try {
                    return $this->getRepository()->getWebspaceNode(
                        $webspace,
                        $language,
                        $depth,
                        $ghostContent
                    );
                } catch (DocumentNotFoundException $ex) {
                    return;
                }
            }
        );

        return $this->handleView($view);
    }
384228
public function forgotPassword(Request $request)
    {
        $form = $this->app->form(new PhraseaForgotPasswordForm());
        $service = $this->getRecoveryService();

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

                if ($form->isValid()) {
                    $data = $form->getData();

                    try {
                        $service->requestPasswordResetToken($data['email'], true);
                    }
                    catch (InvalidArgumentException $ex) {
                        /** @Ignore */
                        $message = $this->app->trans($ex->getMessage());
                        throw new FormProcessingException($message, 0, $ex);
                    }

                    $this->app->addFlash('info', $this->app->trans('phraseanet:: Un email vient de vous etre envoye'));

                    return $this->app->redirectPath('login_forgot_password');
                }
            }
        } catch (FormProcessingException $e) {
            $this->app->addFlash('error', $e->getMessage());
        }

        return $this->render('login/forgot-password.html.twig', array_merge(
            $this->getDefaultTemplateVariables($request),
            [ 'form'  => $form->createView() ]
        ));
    }
324267
public function run(Request $request) {
		$page = $this->getServiceContainer()->getKernel()->getApplication()->getPage();
		$page->setTitle($this->getServiceContainer()->getTranslator()->trans('profile'));

		$payload = new Blank();
		if ($request->isMethod('POST')) {
			$post = $request->request;
			$user = $this->getServiceContainer()->getAuthManager()->getUser();
			$domain = new UserDomain($this->getServiceContainer());
			$serializer = User::getSerializer();

			$fields = $serializer->getFields();
			$fields[] = 'display_name_user_select';
			$attribs = [];

			foreach ($fields as $field) {
				if ($post->has($field)) {
					$attribs[$field] = $post->get($field);
				}
			}

			$payload = $domain->update($user->getId(), ['attributes' => $attribs]);
		}
		return $this->responder->run($request, $payload);
	}
283097
public function submit(Request $request)
    {
        try {
            $response = $this->browser->call(
                $this->buildUrl($request),
                $request->getMethod(),
                $request->getHeaders(),
                $request->getData()
                );
              
            $response = ResponseFactory::createResponse($response, $request);
            return $response;
        } catch(\Exception $e) {
            throw new Exception\OpenSearchServerException('Error while connecting to OpenSearchServer: ' . $e->getMessage(), 1);
        } 
    }
335648
public function postLogin(Request $request)
    {
        $this->loginValidator($request->all())->validate();

        $credentials = $request->only([$this->username(), 'password']);
        $remember = $request->get('remember', false);

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

        return back()->withInput()->withErrors([
            $this->username() => $this->getFailedLoginMessage(),
        ]);
    }
678936
public function login(Request $request)
    {
        if ($request->session()->has('eyewitness:auth') || Eye::check($request)) {
            return redirect(route('eyewitness.dashboard').'#overview');
        }

        if (config('eyewitness.login_disabled', false)) {
            return redirect('/');
        }

        return view('eyewitness::login');
    }
134841
public function execute( Request $request )
    {
        $controllerClass = $request->attributes->get('_controller');
        if( !($this->isJwtRequired($controllerClass))) {
            return null;
        }

        if( !$this->authoriser->isAuthorised( $request ) ) {
            return new JsonResponse( ['error' => 'Invalid token'], 403 );
        }
        return null;
    }