src/Web/User.php
public function getIdentity()
    {
        if ($this->_identity === false || $this->_identity === null) {
            return null;
        }

        return $this->_identity;
    }
public function getIdentity()
    {
        if ($this->_identity === false || $this->_identity === null) {
            return null;
        }

        return $this->_identity;
    }
Returns the identity object associated with the currently logged-in user.
This is only useful when [[enableSession]] is true.
@return IdentityInterface|null|false the identity object associated with the currently logged-in user.
`null` is returned if the user is not logged in (not authenticated).
@see login()
@see logout()
@see getIdentityAsync()