-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthmanager.h
51 lines (38 loc) · 1.08 KB
/
authmanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef AUTHMANAGER_H
#define AUTHMANAGER_H
#include <QObject>
#include "apis.h"
#include <qstring.h>
#include <QtNetwork\qnetworkaccessmanager.h>
#include <QtNetwork\qnetworkreply.h>
#include <QtCore\qjsondocument.h>
#include <QtCore\qjsonobject.h>
#include <QtCore\qurl.h>
#include <QtCore\qurlquery.h>
#include <QEventLoop>
class AuthManager : public QObject
{
Q_OBJECT
public:
AuthManager(QObject *parent);
~AuthManager();
void authenricate_login(QString email, QString password);
signals:
void handle_error(QJsonObject error_dict,int status_code);
void handle_auth_success(QJsonObject info_dict);
private:
bool authenticated = false;
bool error_happened = false;
QString error_value = "";
QString error_description = "";
/*email and passoword*/
QString email, password;
/*auth token which will return from the request if success*/
QString auth_token;
/*qt network manager which is required to make requests*/
QNetworkAccessManager * manager;
QNetworkReply *reply;
/*Functions*/
QJsonObject __post_resquest(QString url, QJsonObject params);
};
#endif // AUTHMANAGER_H