Authenticate user from request

@param array $request
@return bool|null
774737
public function authenticate($request = [])
    {
        if ($request) {
            $this->email = clean($request['email']);
            $this->password = $this->getPasswordHelper()->hash(clean($request['password']));
        } else {
            $this->password = $this->getPasswordHelper()->hash(clean($this->password));
        }

        $query = $this->getManager()->newQuery();

        $query->where("email = ?", $this->email);
        $query->where("password = ?", $this->password);

        /** @var User $user */
        $user = $this->getManager()->findOneByQuery($query);

        if ($user) {
            $this->writeData($user->toArray());
            $this->doAuthentication();
        }

        return $this->authenticated();
    }
1309533
protected function authenticate($request, array $guards)
    {
        if (empty($guards)) {
            $guards = [null];
        }

        foreach ($guards as $guard) {
            if ($this->auth->guard($guard)->check()) {
                return $this->auth->shouldUse($guard);
            }
        }

        throw new AuthenticationException(
            'Unauthenticated.', $guards, $this->redirectTo($request)
        );
    }
1241692
protected function authenticate($request) : bool
  {
    $bearer = substr($request->header('Authorization'), 6);
    $token  = explode(' ', $bearer)[1];

    try {
      $payLoad = $this->validateToken($token);
    }
    catch (TokenValidatorException $e) {
      $this->fails($e);
      cancel();
    }

    $userid   = $payLoad['iss'];
    $provider = $payLoad['pro'];

    $model = config('auth.provider.' . $provider . '.model');

    Auth::grant($model::where('id', $userid)->firstOrFail());

    return true;
  }
30258
protected function authorize(Request $request)
    {
        $isAuthorized = true;

        // if authorization is required check it as well
        if (($authorizationClosure = $this->getAuthorizationClosure()) !== null) {
            $isAuthorized = $authorizationClosure($request);
        }

        return $isAuthorized;
    }
661097
protected function insertCredentials($request) {
		$request->setData('Username', $this->api_username);
		$request->setData('Password', $this->api_password);

		$signature = $this->signMerchantRequest($request);
		if($signature === FALSE) {
			return FALSE;
		}
		$request->setParam('Signature', $signature);

		return TRUE;
	}
1237820
public function authorizeCSRF(array $request)
	{
		$t = $request[$this->_csrf_submittedvaluename];
		if ( is_null($t) )
			$t = '';
		
		
		// if CSRF submitted value in request begins with '!' it means it has been hashed so that the real CSRF value is not disclosed in GET, history, cache, etc.
		if ( strpos($t, '!') === 0 )
			$b = hash_equals($this->getHashedCSRFCookie(), $t);
		else
			$b = hash_equals($this->getCSRFCookie(), $t);

		
		// if CSRF cookie exists, comparing with double-submitted cookie as a request value
		if ( !$b )
			throw new SecureRequestHelper\CSRFException('CSRF security validation failed');
		
		return true;
	}
194254
public function setRequest(array $request)
    {
        parent::setRequest($request);

        if (isset($this->_request->return)) {
            $return = $this->getService('com:people.filter.return')
                           ->sanitize($this->_request->return);
            $this->_request->return = $return;
            $this->return = $return;
        }

        return $this;
    }
483682
public function authenticate(Request $request)
    {
        $channelName = $request->input('channel_name');

        $channel = preg_replace('/^(private|presence)\-/', '', $channelName, 1, $count);

        if (($count == 1) && is_null($user = $request->user())) {
            // For the private and presence channels, the Broadcasting needs a valid User instance,
            // but it is not available for the non authenticated users (guests) within Auth System.
            // For the guests, we will use a cached GuestUser instance, with a random string as ID.

            $request->setUserResolver(function ()
            {
                if (! isset($this->authGuest)) {
                    $session = $this->container['session'];

                    if (empty($id = $session->get('broadcasting.guest'))) {
                        $session->set('broadcasting.guest', $id = dechex(time()) . Str::random(16));
                    }

                    return $this->authGuest = new GuestUser($id);
                }

                return $this->authGuest;
            });
        }

        return $this->verifyUserCanAccessChannel($request, $channel);
    }
812881
protected function attemptLogin(Request $request)
    {
        if ($this->username() === 'email') {
            return $this->attemptLoginAtAuthenticatesUsers($request);
        }
        if (! $this->attemptLoginAtAuthenticatesUsers($request)) {
            return $this->attempLoginUsingUsernameAsAnEmail($request);
        }
        return false;
    }
983560
public function authenticate(Request $request)
    {
        $form = $this->app->form(new PhraseaAuthenticationForm($this->app));
        $redirector = function (array $params = []) {
            return $this->app->redirectPath('homepage', $params);
        };

        try {
            return $this->doAuthentication($request, $form, $redirector);
        } catch (AuthenticationException $e) {
            return $e->getResponse();
        }
    }
985790
protected function authenticateRequest(Request $request)
    {
        if ($this->authenticator && $this->authenticate) {
            return $this->authenticator->authenticate($request);
        }

        return $request;
    }
1362238
protected function attemptAuthentication(Request $request)
    {
        $myRequest = $this->duplicateRequest($request);

        if (!$this->getRelyingParty()->supports($myRequest)) {
            return null;
        }

        try {
            $tokenOrResponse = $this->getRelyingParty()->manage($myRequest);
        } catch (AuthenticationException $ex) {
            throw $ex;
        } catch (\Exception $ex) {
            $msg = "Appsco OAuth failed";
            if ($ex instanceof AppscoOAuthException) {
                $msg .= ': '.$ex->getMessage();
            }
            throw new AuthenticationException($msg, 0, $ex);
        }

        if ($tokenOrResponse instanceof Response) {

            return $tokenOrResponse;
        }

        if ($tokenOrResponse instanceof AppscoToken) {
            try {

                $result = $this->authenticationManager->authenticate($tokenOrResponse);

                $this->setLocale($tokenOrResponse, $request);

                return $result;

            } catch (AuthenticationException $e) {
                $e->setToken($tokenOrResponse);
                throw $e;
            }
        }

        return null;
    }
782264
public function setRequest(array $request)
    {
        $this->_request = new LibBaseControllerRequest();

        foreach ($request as $key => $value) {
            $this->_request->$key = $value;
            $this->$key = $value;
        }

        return $this;
    }
1207095
public function loadDataFromRequest(array $request)
    {
        if ($this->attributeKey !== null) {
            // We need to do this because of the request whitelist + the weird request
            // namespacing we do with attribute forms.
            $this->data['akID'][$this->attributeKey->getAttributeKeyID()]
                = $request['akID'][$this->attributeKey->getAttributeKeyID()];
        }
    }
1148175
public function authenticate(Request $request)
    {
        return $request->get('username') === $this->username
            && password_verify($request->get('password'), $this->password);
    }
652233
public function decodeRequest(array $request)
    {
        foreach ($request as $key => $value) {
            if (is_array($value)) {
                $request[ $key ] = $this->decodeRequest($value);
            } elseif (strpos($key, '[')) {
                preg_match('/(.+?)\[(.+?)\]/', $key, $matches);
                list($match, $name, $subKey) = $matches;

                if (!isset($request[ $name ])) {
                    $request[ $name ] = array();
                }

                $request[ $name ][ $subKey ] = $value;
                unset($request[ $key ]);
            }
        }
        return $request;
    }
758331
public function isAuthorised( Request $request )
    {
        $header = $request->headers->get( 'Authorization' );
        $context = new Context( EncryptionFactory::create( $this->algorithm ) );

        if ( $header ) {
            try{
                $this->token = $this->jwt->deserialize( $this->extractJwtFromHeader($header) );
            } catch ( \Exception $e ){
                return false;
            }
        }

        if ( $this->algorithm instanceof None ) {
            return false;
        }

        if( $this->isExpired() || !$this->hasUserId() || !$this->isAllowedAppId() ) {
            return false;
        }

        try {
            return $this->jwt->verify( $this->token, $context );
        } catch ( VerificationException $e ) {
            return false;
        }
    }