Fix rare error for logging in

This commit is contained in:
loki-47-6F-64 2022-08-09 11:07:08 +02:00
parent aba2c3c9c5
commit b778370a52
2 changed files with 15 additions and 1 deletions

View File

@ -142,9 +142,19 @@ class GalaxyConfig
return this->filepath;
}
void resetClient() {
std::lock_guard<std::mutex> lock(m);
if(token_json.isMember("client_id")) {
token_json["client_id"] = default_client_id;
}
if(token_json.isMember("client_secret")) {
token_json["client_secret"] = default_client_secret;
}
}
std::string getClientId()
{
std::unique_lock<std::mutex> lock(m);
std::lock_guard<std::mutex> lock(m);
if(token_json.isMember("client_id")) {
return token_json["client_id"].asString();
}
@ -154,6 +164,7 @@ class GalaxyConfig
std::string getClientSecret()
{
std::lock_guard<std::mutex> lock(m);
if(token_json.isMember("client_secret")) {
return token_json["client_secret"].asString();
}

View File

@ -264,6 +264,9 @@ std::vector<gameItem> Website::getGames()
// Login to GOG website
int Website::Login(const std::string& email, const std::string& password)
{
// Reset client id and client secret to ensure we can log-in
Globals::galaxyConf.resetClient();
int res = 0;
std::string postdata;
std::ostringstream memory;