diff options
author | George Hazan <ghazan@miranda.im> | 2020-12-03 17:18:44 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-12-03 17:18:44 +0300 |
commit | 360c80ddd03d84b257bb797463fceffa545c1139 (patch) | |
tree | 9aa309cccbd2d7f7d38843f0219b2ad1bf110d66 /protocols/Discord | |
parent | 934e8aa533c20c2ffe97efd597bfdba237cf5f29 (diff) |
minor code cleaning
Diffstat (limited to 'protocols/Discord')
-rw-r--r-- | protocols/Discord/src/http.cpp | 3 | ||||
-rw-r--r-- | 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(); } |