From 8b650dc00a27a5eafdffd011cb0e51472074671b Mon Sep 17 00:00:00 2001 From: Anonymous275 <36374260+Anonymous-275@users.noreply.github.com> Date: Mon, 5 Sep 2022 02:42:36 +0300 Subject: [PATCH] fix null Key pull request #44 --- src/Network/Login.cpp | 2 +- src/gui/Gui.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Network/Login.cpp b/src/Network/Login.cpp index 99141ed..166ccd3 100644 --- a/src/Network/Login.cpp +++ b/src/Network/Login.cpp @@ -9,7 +9,7 @@ #include "Logger.h" void UpdateKey(const std::string& newKey) { - if (!newKey.empty()) { + if (!newKey.empty() && std::isalnum(newKey[0])) { std::ofstream Key("key"); if (Key.is_open()) { Key << newKey; diff --git a/src/gui/Gui.cpp b/src/gui/Gui.cpp index f22b15d..bdcaa7e 100644 --- a/src/gui/Gui.cpp +++ b/src/gui/Gui.cpp @@ -379,7 +379,9 @@ void CheckKey() { Json d = Json::parse(Buffer, nullptr, false); if (Buffer == "-1" || Buffer.at(0) != '{' || d.is_discarded()) { + LOG(ERROR) << Buffer; wxMessageBox("Couldn't connect to auth server, you might be offline!", "Warning", wxICON_WARNING); + UpdateKey(""); return; } if (d["success"].get()) {