From 31835083735bc193b93b8823a8bf2177229670ef Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 30 Oct 2021 03:13:58 -0400 Subject: [PATCH] Unset user token if invalid. --- src/library.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/library.cpp b/src/library.cpp index cb1fbf8f..0f1ab600 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -158,11 +158,22 @@ void checkUpdates() { std::string userUrl = API_URL + "/user"; json_t* userResJ = network::requestJson(network::METHOD_GET, userUrl, NULL, getTokenCookies()); if (!userResJ) { - DEBUG("User failed"); + WARN("Request for user account failed"); + updateStatus = "Could not query user account"; return; } DEFER({json_decref(userResJ);}); + json_t* userErrorJ = json_object_get(userResJ, "error"); + if (userErrorJ) { + std::string userError = json_string_value(userErrorJ); + WARN("Request for user account error: %s", userError.c_str()); + // Unset token + settings::token = ""; + refreshRequested = true; + return; + } + // Get library manifests std::string manifestsUrl = API_URL + "/library/manifests"; json_t* manifestsReq = json_object();