summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2021-10-05 11:41:15 +0500
committerElzorFox <elzorfox@ya.ru>2021-10-05 11:41:15 +0500
commit9f6df6557ccf55656c9b2504e12372664da1c66f (patch)
tree0d1468d58f9bf94261f660eb55f01e631f0c56eb
parent685d7ca062ead553f5db6c9e1774b76ef123efbb (diff)
VKontakte: fix 2FA
-rw-r--r--protocols/VKontakte/src/misc.cpp5
-rw-r--r--protocols/VKontakte/src/vk_files.cpp2
-rw-r--r--protocols/VKontakte/src/vk_proto.h2
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp6
4 files changed, 8 insertions, 7 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 2f3d8f74e6..2f7634e9a2 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -475,7 +475,7 @@ CMStringW CVkProto::RunRenameNick(LPCWSTR pwszOldName)
/////////////////////////////////////////////////////////////////////////////////////////
-void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr)
+void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr, CMStringA szDefDomain)
{
debugLogA("CVkProto::GrabCookies");
for (int i = 0; i < nhr->headersCount; i++) {
@@ -499,6 +499,9 @@ void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr)
szDomain = szToken.Mid(7);
}
+ if (szDomain.IsEmpty() && !szDefDomain.IsEmpty())
+ szDomain = szDefDomain;
+
if (!szCookieName.IsEmpty() && !szDomain.IsEmpty()) {
bool bFound = false;
for (auto &it : m_cookies)
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index 6b2dfda9e2..01e1f30032 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -332,7 +332,7 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
id = jnDoc["id"].as_int();
owner_id = jnDoc["owner_id"].as_int();
}
- else{
+ else {
id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["id"].as_int() : (*jnResponse.begin())["id"].as_int();
owner_id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["owner_id"].as_int() : (*jnResponse.begin())["owner_id"].as_int();
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index e87bc49374..5b1b3920d8 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -344,7 +344,7 @@ private:
bool AutoFillForm(char*, CMStringA&, CMStringA&);
CMStringW RunConfirmationCode(LPCWSTR pwszTitle);
CMStringW RunRenameNick(LPCWSTR pwszOldName);
- void GrabCookies(NETLIBHTTPREQUEST *nhr);
+ void GrabCookies(NETLIBHTTPREQUEST *nhr, CMStringA szDefDomain = "");
void ApplyCookies(AsyncHttpRequest*);
bool IsAuthContactLater(MCONTACT hContact);
bool AddAuthContactLater(MCONTACT hContact);
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 6be3e23db6..692faaeaa5 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -21,10 +21,10 @@ UINT_PTR CVkProto::m_timer;
mir_cs CVkProto::m_csTimer;
char szBlankUrl[] = "https://oauth.vk.com/blank.html";
-char sz2FA[] = "https://m.vk.com/login?act=authcheck";
char Score[] = "friends,photos,audio,docs,video,wall,messages,offline,status,notifications,groups";
static char VK_TOKEN_BEG[] = "access_token=";
static char VK_LOGIN_DOMAIN[] = "https://m.vk.com";
+static char VK_COOKIE_DOMAIN[] = ".vk.com";
static char fieldsName[] = "id, first_name, last_name, photo_100, bdate, sex, timezone, "
"contacts, last_seen, online, status, country, city, relation, interests, activities, "
"music, movies, tv, books, games, quotes, about, domain";
@@ -198,7 +198,7 @@ void CVkProto::OnLoggedOut()
void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest*)
{
debugLogA("CVkProto::OnOAuthAuthorize %d", reply->resultCode);
- GrabCookies(reply);
+ GrabCookies(reply, VK_COOKIE_DOMAIN);
if (reply->resultCode == 404 && !m_bErr404Return) {
m_bErr404Return = true;
@@ -253,8 +253,6 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest*)
ApplyCookies(pRedirectReq);
m_prevUrl = pRedirectReq->m_szUrl;
}
- if (!_strnicmp(pszLocation, sz2FA, sizeof(sz2FA) - 1))
- pRedirectReq->m_szUrl = sz2FA;
pRedirectReq->m_bApiReq = false;
pRedirectReq->bIsMainConn = true;
Push(pRedirectReq);