src/Web/User.php
public function getIdentityAsync($autoRenew = true)
    {
        if ($this->_identity === false) {
            if ($this->enableSession && $autoRenew) {
                $this->_identity = null;
                return $this->renewAuthStatus()
                    ->then(null, function($e) {
                        $this->_identity = false;
                        return reject($e);
                    })->then(function() {
                        return $this->_identity;
                    });
            } else {
                return reject(null);
            }
        } else {
            return resolve($this->_identity);
        }
    }
public function getIdentityAsync($autoRenew = true)
    {
        if ($this->_identity === false) {
            if ($this->enableSession && $autoRenew) {
                $this->_identity = null;
                return $this->renewAuthStatus()
                    ->then(null, function($e) {
                        $this->_identity = false;
                        return reject($e);
                    })->then(function() {
                        return $this->_identity;
                    });
            } else {
                return reject(null);
            }
        } else {
            return resolve($this->_identity);
        }
    }
Returns the identity object associated with the currently logged-in user.
When [[enableSession]] is true, this method may attempt to read the user's authentication data
stored in session and reconstruct the corresponding identity object, if it has not done so before.
@param bool $autoRenew whether to automatically renew authentication status if it has not been done so before.
This is only useful when [[enableSession]] is true.
@return ExtendedPromiseInterface with 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 getIdentity()