diff options
author | Robert Pösel <robyer@seznam.cz> | 2016-07-10 13:25:13 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2016-07-10 13:25:13 +0000 |
commit | 2c20deba9b17ce81c30c288de9a014e8eb7f6762 (patch) | |
tree | ac9bb9e647999877ab0efe819229cec1f4b31939 /protocols/FacebookRM | |
parent | 6d59534a80a984eba4f855315b73fc39f3e3a6e6 (diff) |
Facebook: Fix and improve (= ask user) approving last unknown login; version bump
This will show messagebox with question to user. When approved, login will correctly continue, otherwise login is canceled and user needs to revoke it via web browser.
git-svn-id: http://svn.miranda-ng.org/main/trunk@17084 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 57 | ||||
-rw-r--r-- | protocols/FacebookRM/src/version.h | 2 |
2 files changed, 41 insertions, 18 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index c847279530..0196d58c57 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -910,25 +910,46 @@ bool facebook_client::login(const char *username, const char *password) } // Check if we need to approve also last unapproved device - if (resp.data.find("name=\"name_action_selected\"") == std::string::npos) { - // 1) Continue + + // 1) Continue (it might have been sent with approval code above already) + if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos) { inner_data = "submit[Continue]=Continue"; inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); inner_data += "&fb_dtsg=" + utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); resp = flap(REQUEST_SETUP_MACHINE, &inner_data); + } + + // In this step might be needed identity confirmation + if (resp.data.find("name=\"birthday_captcha_") != std::string::npos) { + // Account is locked and needs identity confirmation + client_notify(TranslateT("Login error: Your account is temporarily locked. You need to confirm this device from web browser.")); + parent->debugLogA("!!! Login error: Birthday confirmation."); + return handle_error("login", FORCE_QUIT); + } - // In this step might be needed identity confirmation - if (resp.data.find("name=\"birthday_captcha_") != std::string::npos) { - // Account is locked and needs identity confirmation - client_notify(TranslateT("Login error: Your account is temporarily locked. You need to confirm this device from web browser.")); - parent->debugLogA("!!! Login error: Birthday confirmation."); - return handle_error("login", FORCE_QUIT); + // 2) Approve last unknown login + if (resp.data.find("name=\"submit[This was me]\"") != std::string::npos) { + CMString tszTitle; + tszTitle.AppendFormat(_T("%s - %s"), parent->m_tszUserName, TranslateT("Check last login")); + CMString tszMessage(TranslateT("Do you recognize this activity?")); + + std::string activity = utils::text::slashu_to_utf8(utils::text::source_get_value(&resp.data, 3, "<body", "</strong></div>", "</div>")); + activity = utils::text::trim(utils::text::html_entities_decode(utils::text::remove_html(activity))); + if (!activity.empty()) { + tszMessage.AppendFormat(_T("\n\n%s"), ptrT(mir_utf8decodeT(activity.c_str()))); } - // 2) Approve last unknown login - // inner_data = "submit[I%20don't%20recognize]=I%20don't%20recognize"; // Don't recognize - this will force to change account password - inner_data = "submit[This%20is%20Okay]=This%20is%20Okay"; // Recognize - inner_data += "&submit[This is Okay]=This is Okay"; // I don't know whether it's with classic spaces now or not + if (MessageBox(0, tszMessage, tszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1) == IDYES) { + // Recognized activity, will continue with login + inner_data = "submit[This was me]=This was me"; + } else { + // Don't recognize - this will force to change account password + inner_data = "submit[This wasn't me]=This wasn't me"; + + // We won't continue with this and rather cancel connecting right away, because we don't want to handle password changing via Miranda + client_notify(TranslateT("Login error: You need to confirm last unknown login or revoke it from web browser.")); + return handle_error("login", FORCE_QUIT); + } inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); inner_data += "&fb_dtsg=" + utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); resp = flap(REQUEST_SETUP_MACHINE, &inner_data); @@ -942,11 +963,13 @@ bool facebook_client::login(const char *username, const char *password) } // Save this actual device - inner_data = "submit[Continue]=Continue"; - inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); - inner_data += "&fb_dtsg=" + utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); - inner_data += "&name_action_selected=save_device"; // Save device - or "dont_save" - resp = flap(REQUEST_SETUP_MACHINE, &inner_data); + if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos) { + inner_data = "submit[Continue]=Continue"; + inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); + inner_data += "&fb_dtsg=" + utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); + inner_data += "&name_action_selected=save_device"; // Save device - or "dont_save" + resp = flap(REQUEST_SETUP_MACHINE, &inner_data); + } } else if (resp.data.find("name=\"submit[Get Started]\"") != std::string::npos) { if (!parent->getBool(FACEBOOK_KEY_TRIED_DELETING_DEVICE_ID)) { diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index 71ef6c5de1..f39c060b13 100644 --- a/protocols/FacebookRM/src/version.h +++ b/protocols/FacebookRM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 #define __RELEASE_NUM 14 -#define __BUILD_NUM 0 +#define __BUILD_NUM 1 #include <stdver.h> |