diff options
author | George Hazan <ghazan@miranda.im> | 2017-06-05 15:16:22 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-06-05 15:16:22 +0300 |
commit | a988d6727c150db41c5bfb222190d147b98f3b68 (patch) | |
tree | 43d202eaafa4536d8ba6aa3382903472e1268be8 /protocols/Discord/src/server.cpp | |
parent | 9a80a756aa3bee92b85e09466b234c4c26c744b4 (diff) |
Discord: attempt to fix problems with unauthorized http requests
Diffstat (limited to 'protocols/Discord/src/server.cpp')
-rw-r--r-- | protocols/Discord/src/server.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index b19def5787..9b86b13fb5 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -159,7 +159,7 @@ void CDiscordProto::RetrieveUserInfo(MCONTACT hContact) void CDiscordProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) { - MCONTACT hContact = (MCONTACT)pReq->pUserInfo; + MCONTACT hContact = (UINT_PTR)pReq->pUserInfo; if (pReply->resultCode != 200) { if (hContact == 0) ConnectionFailed(LOGINERR_WRONGPASSWORD); @@ -183,6 +183,13 @@ void CDiscordProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpReques if (hContact == 0) { m_ownId = id; + for (int i=0; i < pReply->headersCount; i++) + if (!strcmp(pReply->headers[i].szName, "Set-Cookie")) { + char *p = strchr(pReply->headers[i].szValue, ';'); + if (p) *p = 0; + m_szAccessCookie = mir_strdup(pReply->headers[i].szValue); + } + OnLoggedIn(); } else { @@ -245,7 +252,7 @@ void CDiscordProto::SetServerStatus(int iStatus) void CDiscordProto::OnReceiveAuth(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) { - MCONTACT hContact = (MCONTACT)pReq->pUserInfo; + MCONTACT hContact = (UINT_PTR)pReq->pUserInfo; if (pReply->resultCode == 204) RetrieveUserInfo(hContact); } @@ -267,7 +274,7 @@ void CDiscordProto::OnReceiveCreateChannel(NETLIBHTTPREQUEST *pReply, AsyncHttpR void CDiscordProto::OnReceiveMessage(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) { - MCONTACT hContact = (MCONTACT)pReq->pUserInfo; + MCONTACT hContact = (UINT_PTR)pReq->pUserInfo; bool bSucceeded = true; if (pReply->resultCode != 200 && pReply->resultCode != 204) |