diff --git a/apirequest.cpp b/apirequest.cpp index f4f1246..48d557f 100644 --- a/apirequest.cpp +++ b/apirequest.cpp @@ -1,6 +1,8 @@ #include "accounthelper.h" #include "apirequest.h" #include "config.h" +#include "loginwindow.h" +#include "refreshservice.h" #include #include @@ -55,8 +57,19 @@ void APIRequest::onResponse() int code = mReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); QByteArray content = mReply->readAll(); - emit done(APIResponse(code, content)); deleteLater(); - qDebug("Request: %s - %d - %s", mURI.toStdString().c_str(), code, content.toStdString().c_str()); + + + // Check if login token was destroyed + if(code == 412) { + AccountHelper::RemoveLoginToken(); + RefreshService::stopService(); + LoginWindow().exec(); + return; + } + + + emit done(APIResponse(code, content)); + } diff --git a/wsclient.cpp b/wsclient.cpp index ffb89a8..744b0f0 100644 --- a/wsclient.cpp +++ b/wsclient.cpp @@ -6,10 +6,10 @@ WsClient::WsClient(QObject *parent) : QObject(parent) { - startConnect(); - connect(&mWebSocket, &QWebSocket::connected, this, &WsClient::onConnected); connect(&mWebSocket, &QWebSocket::disconnected, this, &WsClient::onConnectionError); + + startConnect(); } void WsClient::startConnect()