diff --git a/api_request.cpp b/api_request.cpp index fa54221..1eb0fbc 100644 --- a/api_request.cpp +++ b/api_request.cpp @@ -1,6 +1,8 @@ #include #include +#include + #include "api_request.h" #include "config.h" @@ -14,6 +16,12 @@ ApiRequest::ApiRequest(const std::string &uri, bool needLogin) { this->addArg("serviceName", API_CLIENT_NAME); this->addArg("serviceToken", API_CLIENT_TOKEN); + + if(needLogin) { + const auto tokens = AccountHelper::loginTokens(); + this->addArg("userToken1", tokens[0]); + this->addArg("userToken2", tokens[1]); + } } void ApiRequest::addArg(const std::string &name, const std::string &value) diff --git a/helpers/accounthelper.cpp b/helpers/accounthelper.cpp index 31874e4..3d3dce3 100644 --- a/helpers/accounthelper.cpp +++ b/helpers/accounthelper.cpp @@ -39,6 +39,12 @@ LoginResult AccountHelper::Login(const std::string &email, const std::string &pa AccountHelper::mToken1 = tokens.at("token1").as_string(); AccountHelper::mToken2 = tokens.at("token2").as_string(); + + // Get current user ID + auto response = ApiRequest("user/getCurrentUserID", true).exec(); + if(response.code() != 200) return ERROR; + AccountHelper::mUserID = response.object().at("userID").as_number().to_int32(); + return SUCCESS; }