Add support for image captcha in Google login

This commit is contained in:
Omar Roth 2019-10-27 00:19:05 -04:00
parent bdeb325bad
commit 0cf187dee7
No known key found for this signature in database
GPG key ID: B8254FB7EC3D37F2
3 changed files with 42 additions and 14 deletions

View file

@ -226,7 +226,7 @@ end
class HTTP::Client
private def handle_response(response)
if @socket.is_a?(OpenSSL::SSL::Socket::Client) && @host.ends_with? "googlevideo.com"
if @socket.is_a?(OpenSSL::SSL::Socket::Client) && @host.ends_with?("googlevideo.com")
close unless response.keep_alive? || @socket.as(OpenSSL::SSL::Socket::Client).@in_buffer_rem.empty?
if @socket.as(OpenSSL::SSL::Socket::Client).@in_buffer_rem.empty?

View file

@ -21,7 +21,8 @@
<hr>
<% if account_type == "invidious" %>
<% case account_type when %>
<% when "invidious" %>
<form class="pure-form pure-form-stacked" action="/login?referer=<%= URI.encode_www_form(referer) %>&type=invidious" method="post">
<fieldset>
<% if email %>
@ -84,7 +85,7 @@
<% end %>
</fieldset>
</form>
<% elsif account_type == "google" %>
<% when "google" %>
<form class="pure-form pure-form-stacked" action="/login?referer=<%= URI.encode_www_form(referer) %>&type=google" method="post">
<fieldset>
<% if email %>
@ -101,11 +102,22 @@
<input required class="pure-input-1" name="password" type="password" placeholder="<%= translate(locale, "Password") %>">
<% end %>
<% if tfa %>
<% if prompt %>
<label for="tfa"><%= translate(locale, prompt) %> :</label>
<input required class="pure-input-1" name="tfa" type="text" placeholder="<%= translate(locale, prompt) %>">
<% end %>
<% if tfa %>
<input type="hidden" name="tfa" value="<%= tfa %>">
<% end %>
<% if captcha %>
<img style="width:50%" src="/Captcha?v=2&ctoken=<%= captcha[:tokens][0] %>"/>
<input type="hidden" name="token" value="<%= captcha[:tokens][0] %>">
<label for="answer"><%= translate(locale, "Answer") %> :</label>
<input type="text" name="answer" type="text" placeholder="<%= translate(locale, "Answer") %>">
<% end %>
<button type="submit" class="pure-button pure-button-primary"><%= translate(locale, "Sign In") %></button>
</fieldset>
</form>