From 257b6b01376f18a77a0e190e87b11fc172f7ac5d Mon Sep 17 00:00:00 2001 From: Sude Date: Wed, 20 Sep 2017 06:59:43 +0300 Subject: [PATCH] Update login check --- include/config.h | 2 +- src/downloader.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/config.h b/include/config.h index fd56c79..2dbcc21 100644 --- a/include/config.h +++ b/include/config.h @@ -66,7 +66,7 @@ class GalaxyConfig bool isExpired() { std::unique_lock 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()); diff --git a/src/downloader.cpp b/src/downloader.cpp index 0989ba6..394605e 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -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;