Authenticate and return bool result of authentication

@return bool
428395
public function authenticate()
    {
        $result = false;

        if (isset($_GET['code'])) {
            $params = array(
                'grant_type' => 'authorization_code',
                'code' => $_GET['code'],
                'client_id' => $this->clientId,
                'client_secret' => $this->clientSecret
            );

            $tokenInfo = $this->post('https://oauth.yandex.ru/token', $params);

            if (isset($tokenInfo['access_token'])) {
                $params = array(
                    'format' => 'json',
                    'oauth_token' => $tokenInfo['access_token']
                );

                $userInfo = $this->get('https://login.yandex.ru/info', $params);

                if (isset($userInfo['id'])) {
                    $this->userInfo = $userInfo;
                    $result = true;
                }
            }
        }

        return $result;
    }
175174
public function authenticateAction()
    {
        if ($this->zfcUserAuthentication()->hasIdentity()) {
            return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }

        $adapter = $this->zfcUserAuthentication()->getAuthAdapter();
        $redirect = $this->params()->fromPost('redirect', $this->params()->fromQuery('redirect', false));

        $result = $adapter->prepareForAuthentication($this->getRequest());

        // Return early if an adapter returned a response
        if ($result instanceof Response) {
            return $result;
        }

        $auth = $this->zfcUserAuthentication()->getAuthService()->authenticate($adapter);

        if (!$auth->isValid()) {
            $this->flashMessenger()->setNamespace('zfcuser-login-form')->addMessage($this->failedLoginMessage);
            $adapter->resetAdapters();
            return $this->redirect()->toUrl(
                $this->url()->fromRoute(static::ROUTE_LOGIN) .
                ($redirect ? '?redirect='. rawurlencode($redirect) : '')
            );
        }

        $redirect = $this->redirectCallback;

        return $redirect();
    }
186110
public function authenticate(){
		bimport('http.request');
		$code=BRequest::GetString('code');
		if(empty($code)) {
			return false;
			}
		$params = array(
			'client_id'	 => $this->clientId,
			'client_secret' => $this->clientSecret,
			'redirect_uri'  => $this->redirectUri,
			'grant_type'	=> 'authorization_code',
			'code'		  => $code
			);
		$tokenInfo = $this->post('https://accounts.google.com/o/oauth2/token', $params);

		if(!isset($tokenInfo['access_token'])) {
			return false;
			}
		$params['access_token'] = $tokenInfo['access_token'];
		$userInfo = $this->get('https://www.googleapis.com/oauth2/v1/userinfo', $params);
		if(!isset($userInfo[$this->socialFieldsMap['socialId']])) {
			BLog::addToLog('[Social.Google] userInfo socialId is not set!',LL_ERROR);
			BLog::addToLog('[Social.Google] userInfo="'.var_export($userInfo,true).'".',LL_ERROR);
			return false;
			}
		$this->userInfo = $userInfo;
		//
		if(!$this->createsession()){
			BLog::addToLog('[Social.Google] Could not create session!',LL_ERROR);
			return false;
			}
		BLog::addToLog('[Social.Google] All done!');
		return true;

		}
810990
public function authenticate(): bool
	{
		try {
			$res = $this->request('account/verify_credentials', 'GET');
			return !empty($res->id);

		} catch (Exception $e) {
			if ($e->getCode() === 401) {
				return false;
			}
			throw $e;
		}
	}
675546
public function authenticateAction()
    {
        if ($this->cmsAuthentication()->hasIdentity()) {
            return $this->redirect()->toRoute($this->options->getLoginRedirectRoute());
        }

        $result = $this->cmsAuthentication()->authenticate();

        // Return early if $result is a response
        if ($result instanceof Response) {
            return $result;
        }

        $redirect = $this->getRedirectParameter();

        if (!$result->isValid()) {
            if ($this->forwardingController) {
                return $this->forward()->dispatch(
                    $this->forwardingController,
                    ['action' => 'login']
                );
            }

            $url = $this->url()->fromRoute(
                $this->options->getLoginRoute(),
                [],
                $redirect ? ['query' => [$this->options->getRedirectKey() => $redirect]] : []
            );

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

        if ($redirect) {
            return $this->redirect()->toUrl($redirect);
        }

        $route = $this->options->getLoginRedirectRoute();
        if (is_callable($route)) {
            $route = $route($this->cmsAuthentication()->getIdentity());
        }

        return $this->redirect()->toRoute($route);
    }
1192006
public function authenticate()
    {
        if (empty($this->request)) {
            throw new Exception\RuntimeException(
                'Request and Response objects must be set before calling authenticate()'
            );
        }

        if ($this->request->getUri()->getScheme() != 'https') {

            return new Result(
                Result::FAILURE_UNCATEGORIZED,
                array(),
                array('Http authentication must be over https')
            );
        }

        return parent::authenticate();
    }
305557
public function isAuthenticated()
    {
        if ($this->isAuthenticated === null) {
            try {
                $this->authenticate();
            } catch (AuthenticationRequiredException $exception) {
            }
        }
        return $this->isAuthenticated;
    }
1068729
public function authenticate()
    {
        if (empty($this->authResult)) {
            if ($this->hasIdentity()) {
                $this->clearIdentity();
            }

            return new Result(
                Result::FAILURE_UNCATEGORIZED,
                null,
                ['no result set']
            );
        }

        if ($this->hasIdentity()) {
            $this->clearIdentity();
        }

        if ($this->authResult->isValid()) {
            $this->getStorage()->write($this->authResult->getIdentity());
        }

        $result = $this->authResult;
        $this->authResult = null;

        return $result;
    }
101871
public function authenticate() {
		if ($this->service->isAuthenticated) {
			$this->id = $this->service->id;
			$this->name = $this->service->getAttribute('name');

			$this->setState('id', $this->id);
			$this->setState('name', $this->name);
			$this->setState('service', $this->service->serviceName);

			// You can save all given attributes in session.
			//$attributes = $this->service->getAttributes();
			//$session = Yii::app()->session;
			//$session['eauth_attributes'][$this->service->serviceName] = $attributes;

			$this->errorCode = self::ERROR_NONE;
		}
		else {
			$this->errorCode = self::ERROR_NOT_AUTHENTICATED;
		}
		return !$this->errorCode;
	}
450041
public function authenticate()
    {
        /* @var $user \Grid\User\Model\User\Structure */
        $user = $this->getModel()
                     ->findByEmail( $this->email );

        if ( empty( $user ) )
        {
            return new Result( Result::FAILURE_IDENTITY_NOT_FOUND, null );
        }

        if ( ! $user->isActive() ||
             ! $user->verifyPassword( $this->password, true ) )
        {
            return new Result( Result::FAILURE_CREDENTIAL_INVALID, null );
        }

        return new Result( Result::SUCCESS, $user );
    }
294278
public function authenticate($username, $password)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$return = false;
		$users = $this->search(array(
			'username'	=> $username,
			'email'		=> $username,
		));
		if ($users && $this->verifyPassword($password, $users[0]['password'])) {
			$this->debug->info('login success');
			$this->log('login', $users[0]['userid']);
			$return = $users[0]['userid'];
		} else {
			$this->debug->warn('login failed');
			$userid = $users
				? $users[0]['userid']
				: null;
			$this->log('loginFail', $userid);
		}
		$this->debug->groupEnd();
		return $return;
	}
861312
public function authenticate()
	{
		// Already got some credentials stored?
		if ($this->token)
		{
			$response = $this->verifyCredentials();

			if ($response)
			{
				return $this->token;
			}
			else
			{
				$this->token = null;
			}
		}

		// Check for callback.
		if (strcmp($this->version, '1.0a') === 0)
		{
			$verifier = $this->input->get('oauth_verifier');
		}
		else
		{
			$verifier = $this->input->get('oauth_token');
		}

		if (empty($verifier))
		{
			// Generate a request token.
			$this->_generateRequestToken();

			// Authenticate the user and authorise the app.
			$this->_authorise();
		}

		// Callback
		else
		{
			$session = $this->application->getSession();

			// Get token form session.
			$this->token = array('key' => $session->get('key', null, 'oauth_token'), 'secret' => $session->get('secret', null, 'oauth_token'));

			// Verify the returned request token.
			if (strcmp($this->token['key'], $this->input->get('oauth_token')) !== 0)
			{
				throw new \DomainException('Bad session!');
			}

			// Set token verifier for 1.0a.
			if (strcmp($this->version, '1.0a') === 0)
			{
				$this->token['verifier'] = $this->input->get('oauth_verifier');
			}

			// Generate access token.
			$this->_generateAccessToken();

			// Return the access token.
			return $this->token;
		}
	}
1356614
function Authenticate() {
		$response = $this->MakeAPICall("POST", "session");
		
		if ($response['success']) {
			$this->last_token = $response['results'][0]['AuthToken'];
			$this->last_token_expire = $response['results'][0]['Expires'];
			
			if ($this->cache) {
				$this->cache->set($this->cache_prefix . 'authtoken', $this->last_token, 86400);
			}
			
			if ( is_callable($this->access_change_callback) ) {
				call_user_func($this->access_change_callback, 'api', array('auth_token' => $this->last_token) );
			}
			
			return true;
		}
		
		return false;
	}
834548
public function authenticate()
    {
        if (!isset($this->account_id)) {
            $accounts = $this->authentication->login();
            $allAccounts = $accounts->getLoginAccounts();
            $account = $allAccounts[0];
            $this->account_id = $account->getAccountId();
        }

        $this->authenticated = true;

        return $this;
    }
1365206
public function authenticateAction()
    {
        if ($this->zfcUserAuthentication()->getAuthService()->hasIdentity()) {
            return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }
        $adapter = $this->zfcUserAuthentication()->getAuthAdapter();
        $redirect = $this->params()->fromPost('redirect', $this->params()->fromQuery('redirect', false));
        
        $routeLoginAdmin = $this->params()->fromPost('routeLoginAdmin', $this->params()->fromQuery('routeLoginAdmin', false));

        $result = $adapter->prepareForAuthentication($this->getRequest());

        // Return early if an adapter returned a response
        if ($result instanceof Response) {
            return $result;
        }

        $auth = $this->zfcUserAuthentication()->getAuthService()->authenticate($adapter);

        if (!$auth->isValid()) {
            $this->flashMessenger()->setNamespace('zfcuser-login-form')->addMessage($this->failedLoginMessage);
            $adapter->resetAdapters();

            if (!empty($routeLoginAdmin)) {
                return $this->redirect()->toUrl($routeLoginAdmin);
            }

            return $this->redirect()->toUrl(
                $this->url()->fromRoute('frontend/zfcuser/login')
                . ($redirect ? '?redirect='.$redirect : '')
            );
        }

        $user = $this->zfcUserAuthentication()->getIdentity();
        $this->getEventManager()->trigger('login.post', $this, array('user' => $user));

        if ($this->getOptions()->getUseRedirectParameterIfPresent() && $redirect) {
            return $this->redirect()->toUrl($redirect);
        }

        return $this->redirect()->toUrl(
            $this->url()->fromRoute(
                $this->getOptions()->getLoginRedirectRoute()
            )
        );
    }
614185
public function authenticate() {
        /* Anti Injection de login */
        $login1 = Security\AntiInjection::antiSqlInjection1($this->getIdentity());
        $login2 = Security\AntiInjection::antiSqlInjection2($login1);
        $identity = Security\AntiInjection::antiSqlInjection3($login2);

        /* Anti Injection de senha */
        $senha1 = Security\AntiInjection::antiSqlInjection1($this->getCredential());
        $senha2 = Security\AntiInjection::antiSqlInjection2($senha1);
        $senha3 = Security\AntiInjection::antiSqlInjection3($senha2);

        /* Criptografa a senha */
        $crypt = new Security\Crypt();
        $credential = $crypt->encrypt($senha3);

        //Define os dados para processar o login
        $this->setIdentity($identity)->setCredential($credential);

        //Faz inner join dos dados do perfil no SELECT do Auth_Adapter
        $select = $this->getDbSelect();

        if (!empty($this->whereConditions)) {
            foreach ($this->whereConditions as $valueWhereConditions) {
                $select->where($valueWhereConditions);
            }
        }

        //Efetua o login
        $result = parent::authenticate();

        //Verifica se o login foi efetuado com sucesso
        if ($result->isValid()) {
            //Recupera o objeto do usuário, sem a senha
            $info = $this->getResultRowObject($this->returnColumns, $this->credentialColumn);

            $storage = new SessionStorage();
            $storage->write($info);

            if ($result->getCode()) {
                return new ResultValidation(ResultValidation::SUCCESS, ((array) $info));
            } else {
                return new ResultValidation(ResultValidation::FAILURE, null);
            }
        } else {
            return new ResultValidation(ResultValidation::FAILURE, null);
        }
    }
55939
protected function authenticate()
    {
        $this->ch = curl_init();

        $headers = array(
            'Accept-Version: v10',
            'Accept: application/json',
        );

        if (!empty($this->auth_string)) {
            $headers[] = 'Authorization: Basic ' . base64_encode($this->auth_string);
        }

        $options = array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => true,
            CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
            CURLOPT_HTTPHEADER => $headers
        );

        curl_setopt_array($this->ch, $options);
    }