From d222d890c51ea95aab36c091a3d9ca18f5698afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Fri, 5 May 2017 23:01:45 +0200 Subject: Facebook: Fix not remembering login --- protocols/FacebookRM/src/communication.cpp | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'protocols') diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index fb2447e8c1..712c5daaf6 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -448,9 +448,8 @@ bool facebook_client::login(const char *username, const char *password) LoginRequest *request = new LoginRequest(); http::response resp = sendRequest(request); - // Also parse cookies set by JavaScript (more variant exists in time, so check all known now) - parseJsCookies("[\"DeferredCookie\",\"addToQueue\",[],[\"", resp.data, cookies); - parseJsCookies("[\"Cookie\",\"setIfFirstPartyContext\",[],[\"", resp.data, cookies); + // Also parse cookies set by JavaScript + parseJsCookies("[\"CookieCore\",\"setWithoutChecksIfFirstPartyContext\",[],[\"", resp.data, cookies); // Parse hidden inputs and other data std::string form = utils::text::source_get_value(&resp.data, 2, ""); @@ -528,10 +527,21 @@ bool facebook_client::login(const char *username, const char *password) break; } } - + + // Save this actual device + if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos + && resp.data.find("name=\"name_action_selected\"") != std::string::npos) { + std::string fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); + std::string nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); + + request = new SetupMachineRequest(fb_dtsg.c_str(), nh.c_str(), "Continue"); + request->Body << "&name_action_selected=save_device"; // Save device - or "dont_save" + resp = sendRequest(request); + } + // Check if we need to approve also last unapproved device - // 1) Continue (it might have been sent with approval code above already) + // 1) Continue to check last unknown login if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos) { std::string fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); std::string nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); @@ -539,7 +549,7 @@ bool facebook_client::login(const char *username, const char *password) request = new SetupMachineRequest(fb_dtsg.c_str(), nh.c_str(), "Continue"); resp = sendRequest(request); } - + // 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 @@ -580,16 +590,6 @@ bool facebook_client::login(const char *username, const char *password) request->Body << "&name_action_selected=save_device"; // Save device - or "dont_save" resp = sendRequest(request); } - - // Save this actual device - if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos) { - std::string fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); - std::string nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); - - request = new SetupMachineRequest(fb_dtsg.c_str(), nh.c_str(), "Continue"); - request->Body << "&name_action_selected=save_device"; // Save device - or "dont_save" - resp = sendRequest(request); - } } else if (resp.data.find("name=\"submit[Get Started]\"") != std::string::npos) { if (!parent->getBool(FACEBOOK_KEY_TRIED_DELETING_DEVICE_ID)) { -- cgit v1.2.3