Return identity if user agent is correct

@return IdentityInterface|null
342609
public function getIdentity(): ?IdentityInterface
    {
        if (!$this->identity) {
            // check user agent
            if (Session::get('auth:agent') === Request::getServer('HTTP_USER_AGENT')) {
                $this->identity = Session::get('auth:identity');
            } else {
                $this->clearIdentity();
            }
        }
        return $this->identity;
    }
682637
public function getIdentity($spec = null, $default = null)
    {
        if ($spec !== null) {
            return isset($this->identity[$spec]) ? $this->identity[$spec] : $default;
        } else {
            return $this->identity;
        }
    }
1285358
public function getAuthObject()
    {
        if (!$this->_resultRow) {
            return false;
        }

        if (null === $this->_tableName || null === $this->_identityColumn || null === $this->_identity) {
            return false;
        }

        $dbSelect = \Doctrine_Query::create()
                ->from("$this->_tableName table")
                ->where("table.$this->_identityColumn = ?", $this->_identity);

        foreach ($this->_conditions as $condition => $value) {
            $dbSelect->addWhere($condition, $value);
        }

        $returnObject = $dbSelect->fetchOne();

        if ($returnObject) {
            return $returnObject;
        } else {
            return false;
        }
    }
1200625
public function id()
	{
		if ($this->loggedOut)
		{
			return null;
		}

		if (!$this->user())
		{
			return null;
		}

		return $this->user()->ID;
	}
320204
private function getUser()
    {
        if (function_exists('auth') && auth()->check()) {
            return auth()->user()->toArray();
        }

        if (class_exists(\Cartalyst\Sentinel\Sentinel::class) && $user = Sentinel::check()) {
            return $user->toArray();
        }

        return null;
    }
22120
protected function get_iauthority()
	{
		if ($this->iuserinfo !== null || $this->ihost !== null || $this->port !== null)
		{
			$iauthority = '';
			if ($this->iuserinfo !== null)
			{
				$iauthority .= $this->iuserinfo . '@';
			}
			if ($this->ihost !== null)
			{
				$iauthority .= $this->ihost;
			}
			if ($this->port !== null)
			{
				$iauthority .= ':' . $this->port;
			}
			return $iauthority;
		}
		else
		{
			return null;
		}
	}
845650
public function getUser()
    {
        // Ensure we have the user info
        if ($this->user === null) {
            $this->exchangeCode();
        }

        if (! is_array($this->user)) {
            return null;
        }

        return $this->user;
    }
1171506
public function id()
	{
		if ( $this->loggedOut )
			return null;

		$id = $this->session->get( $this->getName() );

		if ( is_null( $id ) && $this->acct() )
			$id = $this->acct()->getId();

		return $id;
	}
320806
public function retrieveById($identifier)
    {
        $userService = app()->make(UserService::class);
        $user = $userService->byId($identifier)->get();

        if (! $user) {
            return null;
        }

        return $user;
    }
533033
public function getIdentity() {

		$userId = $this->getUserId();
		if ($userId === NULL) {
			return NULL;
		}

		$identity = SimpleSAML\Module::getModuleURL('openidProvider/user.php/' . $userId);
		return $identity;
	}
171014
public function getIdentifier()
    {
        $identifierAttribute = $this->getFamily()->getAttributeAsIdentifier();
        if ($identifierAttribute) {
            /** @noinspection ExceptionsAnnotatingAndHandlingInspection */

            return $this->get($identifierAttribute->getCode());
        }

        return $this->getId();
    }
710894
public function getIdentityProperty()
    {
        if (is_string($this->_identity_property)) {
            $this->setIdentityProperty($this->_identity_property);
        }

        return $this->_identity_property;
    }
949769
protected function getUserId()
    {
        if (property_exists($this, 'userKey'))
        {
            $userKey = $this->userKey;

            return $this->$userKey;
        }

        if ( ! is_null($this->user_id))
        {
            return $this->user_id;
        }

        return null;
    }
340094
protected function _matchUserAgent()
    {
        $type = self::DEFAULT_BROWSER_TYPE;

        // If we have no identification sequence, just return the default type
        if (empty($this->_config['identification_sequence'])) {
            return $type;
        }

        // Get sequence against which to match
        $sequence = explode(',', $this->_config['identification_sequence']);

        // If a browser type is already configured, push that to the front of the list
        if (null !== ($browserType = $this->getBrowserType())) {
            array_unshift($sequence, $browserType);
        }

        // Append the default browser type to the list if not alread in the list
        if (!in_array($type, $sequence)) {
            $sequence[] = $type;
        }

        // Test each type until we find a match
        foreach ($sequence as $browserType) {
            $browserType = trim($browserType);
            $className   = $this->_getUserAgentDevice($browserType);

            // Attempt to match this device class
            if ($this->_match($className)) {
                $type = $browserType;
                $this->_browserTypeClass[$type] = $className;
                break;
            }
        }

        return $type;
    }
109458
function findIdentityMatch()
    {
        $identity = $this->wrap->findIdentityMatch();
        if (!$identity)
            return false;
        
        $return   = $this->identity_map->clean();
        $return->import($identity);
        return $identity;
    }
331730
final public function getIdentifier($identifier = null)
	{
		if(isset($identifier)) {
		    $result = $this->__service_container->getIdentifier($identifier);
		} else {
		    $result = $this->__service_identifier; 
		}
	    
	    return $result;
	}
1332534
public function getUserInRequest() {
    if (isset($_COOKIE[$this->cookieName])) {
      $user = $this->validateToken($_COOKIE[$this->cookieName],
          $this->clientId);
      if ($user) {
        $accountInfo = $this->getUserById($user->getUserId());
        $accountInfo->setProviderId($user->getProviderId());
        return $accountInfo;
      }
    }
    return null;
  }