mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-11-22 13:29:25 +00:00
Handle the case login tokens are destroyed
This commit is contained in:
parent
e9d1bb6e61
commit
9394e6b153
@ -1,6 +1,8 @@
|
||||
#include "accounthelper.h"
|
||||
#include "apirequest.h"
|
||||
#include "config.h"
|
||||
#include "loginwindow.h"
|
||||
#include "refreshservice.h"
|
||||
|
||||
#include <QHttpPart>
|
||||
#include <QNetworkReply>
|
||||
@ -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));
|
||||
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user