Update login check

This commit is contained in:
Sude 2017-09-20 06:59:43 +03:00
parent edc6486637
commit 257b6b0137
2 changed files with 12 additions and 3 deletions

View File

@ -66,7 +66,7 @@ class GalaxyConfig
bool isExpired()
{
std::unique_lock<std::mutex> lock(m);
bool bExpired = false;
bool bExpired = true; // assume that token is expired
intmax_t time_now = time(NULL);
if (this->token_json.isMember("expires_at"))
bExpired = (time_now > this->token_json["expires_at"].asLargestInt());

View File

@ -178,15 +178,24 @@ bool Downloader::isLoggedIn()
if (!bWebsiteIsLoggedIn)
Globals::globalConfig.bLoginHTTP = true;
bool bGalaxyIsLoggedIn = !gogGalaxy->isTokenExpired();
if (!bGalaxyIsLoggedIn)
{
if (gogGalaxy->refreshLogin())
bGalaxyIsLoggedIn = true;
else
Globals::globalConfig.bLoginHTTP = true;
}
bool bIsLoggedInAPI = gogAPI->isLoggedIn();
if (!bIsLoggedInAPI)
Globals::globalConfig.bLoginAPI = true;
/* Only check that website is logged in.
/* Check that website and Galaxy API are logged in.
Allows users to use most of the functionality without having valid API login credentials.
Globals::globalConfig.bLoginAPI can still be set to true at this point which means that if website is not logged in we still try to login to API.
*/
if (bWebsiteIsLoggedIn)
if (bWebsiteIsLoggedIn && bGalaxyIsLoggedIn)
bIsLoggedIn = true;
return bIsLoggedIn;