public function logout($globalLogout=true)
    {
        $this->isLoggingOut = true;

        /** @var UserIdentity $identity */
        $identity = Yii::$app->user->identity;
        if($globalLogout)
            Yii::$app->user->logout();

        try {
            if($identity != null && !empty($identity->sid))
            {
                $token = $this->getAccessToken()->token;
                $headers = [
                    'Authorization' => 'Bearer ' . $token
                ];
                $params = [
                    'sid' => $identity->sid
                ];
                $this->api($this->logoutUrl, 'GET', $params, $headers);
            }
        } catch (Exception $e) {
            Yii::$app->response->redirect(Yii::$app->getHomeUrl());
        }
        return true;
    }