diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-06-15 08:22:23 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-06-15 10:09:25 -0500 |
| commit | a3164177f8e7e3d323006e08755230f850a5fdd9 (patch) | |
| tree | 9cbe5ab2439d1a3098a51deff5f55d6070ead105 | |
| parent | fa6bf21cd15f8f8e7c2f3bb66744402eb99dd3bc (diff) | |
| download | invidious-a3164177f8e7e3d323006e08755230f850a5fdd9.tar.gz invidious-a3164177f8e7e3d323006e08755230f850a5fdd9.tar.bz2 invidious-a3164177f8e7e3d323006e08755230f850a5fdd9.zip | |
Fix SMS for Google login
| -rw-r--r-- | src/invidious.cr | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 4a14a4b7..1550bc8e 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -964,6 +964,11 @@ post "/login" do |env| headers["Cookie"] = URI.unescape(headers["Cookie"]) + if challenge_results[0][3]?.try &.== 7 + error_message = translate(locale, "Account has temporarily been disabled") + next templated "error" + end + if challenge_results[0][-1]?.try &.[5] == "INCORRECT_ANSWER_ENTERED" error_message = translate(locale, "Incorrect password") next templated "error" @@ -1049,21 +1054,21 @@ post "/login" do |env| traceback << "Logging in..." location = challenge_results[0][-1][2].to_s - cookies = HTTP::Cookies.new + cookies = HTTP::Cookies.from_headers(headers) loop do - if !location + if !location || location.includes? "/ManageAccount" break end + # TODO: Occasionally there will be a second page after login confirming + # the user's phone number, which we will likely choke on. + # if location.includes? "SmsAuthInterstitial" + login = client.get(location, headers) headers = login.cookies.add_request_headers(headers) - cookies = HTTP::Cookies.from_headers(headers) - - if cookies["SID"]? - break - end + cookies = HTTP::Cookies.from_headers(headers) location = login.headers["Location"]? end |
