Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix getchat, add logout #33

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,20 @@ void KeyAuth::api::login(std::string username, std::string password)
load_user_data(json[(XorStr("info"))]);
}

void KeyAuth::api::logout()
{
checkInit();

auto data =
XorStr("type=logout") +
XorStr("&sessionid=") + sessionid +
XorStr("&name=") + name +
XorStr("&ownerid=") + ownerid;
auto response = req(data, url);
auto json = response_decoder.parse(response);
load_response_data(json);
}

void KeyAuth::api::chatget(std::string channel)
{
checkInit();
Expand Down
4 changes: 3 additions & 1 deletion auth.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <includes.hpp>
#include <includes.hpp>

#pragma comment(lib, "libcurl.lib")

Expand Down Expand Up @@ -33,6 +33,7 @@ namespace KeyAuth {
void button(std::string value);
void upgrade(std::string username, std::string key);
void login(std::string username, std::string password);
void logout();
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);
Expand Down Expand Up @@ -124,6 +125,7 @@ namespace KeyAuth {
void load_channel_data(nlohmann::json data) {
api::response.success = data["success"];
api::response.message = data["message"];
api::response.channeldata.clear(); //If you do not delete the data before pushing it, the data will be repeated. TTakaTit
for (const auto sub : data["messages"]) {

std::string authoroutput = sub["author"];
Expand Down