From d60a8d0c45ea7903274c570f523b7775125f4e89 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 27 Jul 2021 11:50:05 +0300 Subject: Skype: little crutch for login --- protocols/SkypeWeb/src/skype_oauth.cpp | 20 +++++++++++--------- protocols/SkypeWeb/src/skype_proto.h | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'protocols') diff --git a/protocols/SkypeWeb/src/skype_oauth.cpp b/protocols/SkypeWeb/src/skype_oauth.cpp index e15578a571..6ad4bdbe23 100644 --- a/protocols/SkypeWeb/src/skype_oauth.cpp +++ b/protocols/SkypeWeb/src/skype_oauth.cpp @@ -36,7 +36,7 @@ void CSkypeProto::OnOAuthStart(NETLIBHTTPREQUEST *response, AsyncHttpRequest*) SetStatus(ID_STATUS_OFFLINE); return; } - std::string PPTF = match[1]; + PPFT = match[1]; std::map scookies; for (int i = 0; i < response->headersCount; i++) { @@ -55,7 +55,7 @@ void CSkypeProto::OnOAuthStart(NETLIBHTTPREQUEST *response, AsyncHttpRequest*) cookies["MSPRequ"] = scookies["MSPRequ"]; - PushRequest(new OAuthRequest(login, password, mscookies.c_str(), PPTF.c_str())); + PushRequest(new OAuthRequest(login, password, mscookies.c_str(), PPFT.c_str())); } bool CSkypeProto::CheckOauth(const char *szResponse) @@ -86,13 +86,15 @@ void CSkypeProto::OnOAuthConfirm(NETLIBHTTPREQUEST *response, AsyncHttpRequest * std::smatch match; std::string content = response->pData; - regex = "";; - if (!std::regex_search(content, match, regex)) { - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); - SetStatus(ID_STATUS_OFFLINE); - return; + if (PPFT.empty()) { + regex = "";; + if (!std::regex_search(content, match, regex)) { + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); + SetStatus(ID_STATUS_OFFLINE); + return; + } + PPFT = match[1]; } - std::string PPTF = match[1]; regex = "[&?]opid=(.+?)[&']"; if (!std::regex_search(content, match, regex)) { @@ -114,7 +116,7 @@ void CSkypeProto::OnOAuthConfirm(NETLIBHTTPREQUEST *response, AsyncHttpRequest * } CMStringA mscookies(FORMAT, "MSPRequ=%s;MSPOK=%s;PPAuth=%s;OParams=%s;", cookies["MSPRequ"].c_str(), scookies["MSPOK"].c_str(), scookies["PPAuth"].c_str(), scookies["OParams"].c_str()); - PushRequest(new OAuthRequest(mscookies.c_str(), PPTF.c_str(), opid.c_str())); + PushRequest(new OAuthRequest(mscookies.c_str(), PPFT.c_str(), opid.c_str())); } void CSkypeProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *response, AsyncHttpRequest*) diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 4e0782f5a4..02a34d42b3 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -166,6 +166,7 @@ public: private: bool m_bHistorySynced; + std::string PPFT; std::map cookies; static std::map languages; -- cgit v1.2.3