mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-11-21 21:09:26 +00:00
Extract token from response
This commit is contained in:
parent
4a54dfcaed
commit
dde3ad35df
@ -1,3 +1,5 @@
|
|||||||
|
#include <QJsonDocument>
|
||||||
|
|
||||||
#include "apiresponse.h"
|
#include "apiresponse.h"
|
||||||
|
|
||||||
APIResponse::APIResponse(int code, QByteArray content) :
|
APIResponse::APIResponse(int code, QByteArray content) :
|
||||||
@ -16,7 +18,14 @@ QByteArray APIResponse::getContent() const
|
|||||||
return mContent;
|
return mContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool APIResponse::isError()
|
bool APIResponse::isError()
|
||||||
{
|
{
|
||||||
return mCode != 200;
|
return mCode != 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonObject APIResponse::getObject() const
|
||||||
|
{
|
||||||
|
return QJsonDocument::fromJson(mContent).object();
|
||||||
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -19,6 +20,8 @@ public:
|
|||||||
|
|
||||||
bool isError();
|
bool isError();
|
||||||
|
|
||||||
|
QJsonObject getObject() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mCode;
|
int mCode;
|
||||||
QByteArray mContent;
|
QByteArray mContent;
|
||||||
|
@ -83,7 +83,8 @@ void LoginWindow::onResponse(APIResponse res)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox::information(this, "ok", "success");
|
auto token = res.getObject().value("tokens").toObject().value("token1").toString();
|
||||||
|
QMessageBox::information(this, "ok", token);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginWindow::on_submitButton_clicked()
|
void LoginWindow::on_submitButton_clicked()
|
||||||
|
Loading…
Reference in New Issue
Block a user