summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2021-06-15 11:00:08 +0500
committerElzorFox <elzorfox@ya.ru>2021-06-15 11:00:08 +0500
commiteaa5f40645f0140f39c07b899e80cbd149d4c727 (patch)
tree1c89c72e95ba2b410f41a0fe47716a294d3f67fe
parent0b162a8362eeaa3a2f743aad3439a3dbed359c09 (diff)
VKontakte:
crutch for login after entering confirmation code (VK returns 404 instead of token) update VK_API_VER to 5.131 version bump
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk.h2
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp2
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp26
4 files changed, 25 insertions, 7 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index fe73c99beb..3814afc121 100644
--- a/protocols/VKontakte/src/version.h
+++ b/protocols/VKontakte/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 12
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h
index 75006c5dea..1cf50416c1 100644
--- a/protocols/VKontakte/src/vk.h
+++ b/protocols/VKontakte/src/vk.h
@@ -88,7 +88,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VK_USER_DEACTIVATE_ACTION 9321
-#define VK_API_VER "5.130"
+#define VK_API_VER "5.131"
#define VER_API CHAR_PARAM("v", VK_API_VER)
#define VK_FEED_USER 2147483647L
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index 6b7604ab2c..5f44167637 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -136,7 +136,7 @@ void CVkProto::WorkerThread(void*)
m_bTerminated = m_prevError = false;
m_szAccessToken = getStringA("AccessToken");
- char Score[] = "friends,photos,audio,docs,video,wall,messages,offline,status,notifications,groups";
+ extern char Score[];
CMStringA szAccessScore(ptrA(getStringA("AccessScore")));
if (szAccessScore != Score) {
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 013fadba8b..1b906537bf 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -22,6 +22,7 @@ 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 fieldsName[] = "id, first_name, last_name, photo_100, bdate, sex, timezone, "
@@ -73,6 +74,7 @@ void CVkProto::ShutdownSession()
void CVkProto::ConnectionFailed(int iReason)
{
delSetting("AccessToken");
+ delSetting("Err404Return");
ProtoBroadcastAck(0, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, iReason);
debugLogA("CVkProto::ConnectionFailed ShutdownSession");
@@ -198,6 +200,24 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest*)
debugLogA("CVkProto::OnOAuthAuthorize %d", reply->resultCode);
GrabCookies(reply);
+ if (reply->resultCode == 404 && getBool("Err404Return") == false) {
+ setByte("Err404Return", 1);
+ setString("AccessScore", Score);
+ AsyncHttpRequest* pReq = new AsyncHttpRequest(this, REQUEST_GET, "https://oauth.vk.com/authorize", false, &CVkProto::OnOAuthAuthorize);
+ pReq
+ << INT_PARAM("client_id", VK_APP_ID)
+ << CHAR_PARAM("scope", Score)
+ << CHAR_PARAM("redirect_uri", szBlankUrl)
+ << CHAR_PARAM("display", "mobile")
+ << CHAR_PARAM("response_type", "token")
+ << VER_API;
+ pReq->m_bApiReq = false;
+ pReq->bIsMainConn = true;
+ ApplyCookies(pReq);
+ Push(pReq);
+ return;
+ }
+
if (reply->resultCode == 302) { // manual redirect
LPCSTR pszLocation = Netlib_GetHeader(reply, "Location");
if (pszLocation) {
@@ -217,10 +237,8 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest*)
setString("AccessToken", m_szAccessToken);
RetrieveMyInfo();
}
- else {
- delSetting("AccessToken");
+ else
ConnectionFailed(LOGINERR_NOSERVER);
- }
}
else {
AsyncHttpRequest *pRedirectReq = new AsyncHttpRequest();
@@ -270,7 +288,6 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest*)
}
else {
debugLogA("CVkProto::OnOAuthAuthorize blank ulr found, access_token not found");
- delSetting("AccessToken");
ConnectionFailed(LOGINERR_NOSERVER);
}
return;
@@ -327,6 +344,7 @@ void CVkProto::TrackVisitor()
void CVkProto::RetrieveMyInfo()
{
debugLogA("CVkProto::RetrieveMyInfo");
+ delSetting("Err404Return");
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/users.get.json", true, &CVkProto::OnReceiveMyInfo, AsyncHttpRequest::rpHigh));
}