From 360c80ddd03d84b257bb797463fceffa545c1139 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 3 Dec 2020 17:18:44 +0300 Subject: minor code cleaning --- protocols/Discord/src/http.cpp | 3 +-- protocols/Discord/src/server.cpp | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/protocols/Discord/src/http.cpp b/protocols/Discord/src/http.cpp index b9832098bc..ca4d7d0650 100644 --- a/protocols/Discord/src/http.cpp +++ b/protocols/Discord/src/http.cpp @@ -103,8 +103,7 @@ void CDiscordProto::ServerThread(void*) debugLogA("CDiscordProto::WorkerThread: %s", "entering"); if (m_szAccessToken != nullptr) - // try to receive a response from server - RetrieveMyInfo(); + RetrieveMyInfo(); // try to receive a response from server else { if (mir_wstrlen(m_wszEmail) == 0) { ConnectionFailed(LOGINERR_BADUSERID); diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index 44fabe5123..54ef51fe7d 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -265,16 +265,19 @@ void CDiscordProto::OnReceiveToken(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) } JsonReply root(pReply); - if (!root) + if (!root) { ConnectionFailed(LOGINERR_NOSERVER); - else { - auto &data = root.data(); - CMStringA szToken = data["token"].as_mstring(); - if (szToken.IsEmpty()) - return; + return; + } - m_szAccessToken = szToken.Detach(); - setString("AccessToken", m_szAccessToken); - RetrieveMyInfo(); + auto &data = root.data(); + CMStringA szToken = data["token"].as_mstring(); + if (szToken.IsEmpty()) { + debugLogA("Strange empty token received, exiting"); + return; } + + m_szAccessToken = szToken.Detach(); + setString("AccessToken", m_szAccessToken); + RetrieveMyInfo(); } -- cgit v1.2.3