forked from KeyAuth/keyauth-cpp-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.hpp
131 lines (112 loc) · 3.92 KB
/
auth.hpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <includes.hpp>
#pragma comment(lib, "libcurl.lib")
#define CURL_STATICLIB
struct channel_struct
{
std::string author;
std::string message;
std::string timestamp;
};
namespace KeyAuth {
class api {
public:
std::string name, ownerid, secret, version, url;
api(std::string name, std::string ownerid, std::string secret, std::string version, std::string url) : name(name), ownerid(ownerid), secret(secret), version(version), url(url) {}
void ban(std::string reason = "");
void init();
void check();
void log(std::string msg);
void license(std::string key);
std::string var(std::string varid);
std::string webhook(std::string id, std::string params, std::string body = "", std::string contenttype = "");
void setvar(std::string var, std::string vardata);
std::string getvar(std::string var);
bool checkblack();
void web_login();
void button(std::string value);
void upgrade(std::string username, std::string key);
void login(std::string username, std::string password);
std::vector<unsigned char> download(std::string fileid);
void regstr(std::string username, std::string password, std::string key, std::string email = "");
void chatget(std::string channel);
bool chatsend(std::string message, std::string channel);
void changeusername(std::string newusername);
std::string fetchonline();
void fetchstats();
void forgot(std::string username, std::string email);
class subscriptions_class {
public:
std::string name;
std::string expiry;
};
class data_class {
public:
// app data
std::string numUsers;
std::string numOnlineUsers;
std::string numKeys;
std::string version;
std::string customerPanelLink;
// user data
std::string username;
std::string ip;
std::string hwid;
std::string createdate;
std::string lastlogin;
std::vector<subscriptions_class> subscriptions;
// response data
std::vector<channel_struct> channeldata;
bool success{};
std::string message;
};
data_class data;
private:
std::string sessionid, enckey;
static std::string req(std::string data, std::string url);
void load_user_data(nlohmann::json data) {
api::data.username = data["username"];
api::data.ip = data["ip"];
if (data["hwid"].is_null()) {
api::data.hwid = "none";
}
else {
api::data.hwid = data["hwid"];
}
api::data.createdate = data["createdate"];
api::data.lastlogin = data["lastlogin"];
for (int i = 0; i < data["subscriptions"].size(); i++) { // Prompto#7895 & stars#2297 was here
subscriptions_class subscriptions;
subscriptions.name = data["subscriptions"][i]["subscription"];
subscriptions.expiry = data["subscriptions"][i]["expiry"];
api::data.subscriptions.emplace_back(subscriptions);
}
}
void load_app_data(nlohmann::json data) {
api::data.numUsers = data["numUsers"];
api::data.numOnlineUsers = data["numOnlineUsers"];
api::data.numKeys = data["numKeys"];
api::data.version = data["version"];
api::data.customerPanelLink = data["customerPanelLink"];
}
void load_response_data(nlohmann::json data) {
api::data.success = data["success"];
api::data.message = data["message"];
}
void load_channel_data(nlohmann::json data) {
api::data.success = data["success"];
api::data.message = data["message"];
for (auto sub : data["messages"])
{
std::string authoroutput = sub[("author")];
std::string messageoutput = sub[("message")];
std::string timestampoutput = sub[("timestamp")];
authoroutput.erase(remove(authoroutput.begin(), authoroutput.end(), '"'), authoroutput.end());
messageoutput.erase(remove(messageoutput.begin(), messageoutput.end(), '"'), messageoutput.end());
timestampoutput.erase(remove(timestampoutput.begin(), timestampoutput.end(), '"'), timestampoutput.end());
channel_struct output = { authoroutput , messageoutput, timestampoutput };
api::data.channeldata.push_back(output);
}
}
nlohmann::json response_decoder;
};
}