src/Authentication/AuthenticationService.php
public function getIdentity()
    {
        if ($this->identity instanceof User) {
            return $this->identity;
        }

        $identity = parent::getIdentity();

        if (empty($identity)) {
            $this->clearIdentity();

            return;
        }

        $identity = $this->tableGateway->selectByPrimary($identity);
        if (!($identity instanceof User)) {
            $this->clearIdentity();

            return;
        }

        if (!\in_array($identity->getStatus(), [User::STATUS_ACTIVE])) {
            $this->clearIdentity();

            return;
        }

        $this->identity = $identity;

        return $identity;
    }
public function getIdentity()
    {
        if ($this->identity instanceof User) {
            return $this->identity;
        }

        $identity = parent::getIdentity();

        if (empty($identity)) {
            $this->clearIdentity();

            return;
        }

        $identity = $this->tableGateway->selectByPrimary($identity);
        if (!($identity instanceof User)) {
            $this->clearIdentity();

            return;
        }

        if (!\in_array($identity->getStatus(), [User::STATUS_ACTIVE])) {
            $this->clearIdentity();

            return;
        }

        $this->identity = $identity;

        return $identity;
    }
Returns the authenticated identity or null if no identity is available

@return User|null