From 919413e2b90371d63d88c86305575c17cef6445d Mon Sep 17 00:00:00 2001 From: matthewmcgarvey Date: Wed, 23 Feb 2022 22:39:43 -0600 Subject: [PATCH] Move captcha endpoint into Login route --- src/invidious.cr | 2 -- src/invidious/routes/captcha.cr | 8 -------- src/invidious/routes/login.cr | 7 +++++++ src/invidious/routing.cr | 1 + 4 files changed, 8 insertions(+), 10 deletions(-) delete mode 100644 src/invidious/routes/captcha.cr diff --git a/src/invidious.cr b/src/invidious.cr index dc055e59e..140a9f7b6 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -391,8 +391,6 @@ end Invidious::Routing.post "/subscription_ajax", Invidious::Routes::Subscriptions, :toggle_subscription Invidious::Routing.get "/subscription_manager", Invidious::Routes::Subscriptions, :subscription_manager - - Invidious::Routing.get "/Captcha", Invidious::Routes::Captcha, :get {% end %} Invidious::Routing.get "/ggpht/*", Invidious::Routes::Images, :ggpht diff --git a/src/invidious/routes/captcha.cr b/src/invidious/routes/captcha.cr deleted file mode 100644 index a1d95a4f5..000000000 --- a/src/invidious/routes/captcha.cr +++ /dev/null @@ -1,8 +0,0 @@ -module Invidious::Routes::Captcha - def self.get(env) - headers = HTTP::Headers{":authority" => "accounts.google.com"} - response = YT_POOL.client &.get(env.request.resource, headers) - env.response.headers["Content-Type"] = response.headers["Content-Type"] - response.body - end -end diff --git a/src/invidious/routes/login.cr b/src/invidious/routes/login.cr index 65b337d14..99fc13a2b 100644 --- a/src/invidious/routes/login.cr +++ b/src/invidious/routes/login.cr @@ -481,4 +481,11 @@ module Invidious::Routes::Login env.redirect referer end + + def self.captcha(env) + headers = HTTP::Headers{":authority" => "accounts.google.com"} + response = YT_POOL.client &.get(env.request.resource, headers) + env.response.headers["Content-Type"] = response.headers["Content-Type"] + response.body + end end diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index 5efe1bd81..d539d8916 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -15,6 +15,7 @@ macro define_user_routes Invidious::Routing.get "/login", Invidious::Routes::Login, :login_page Invidious::Routing.post "/login", Invidious::Routes::Login, :login Invidious::Routing.post "/signout", Invidious::Routes::Login, :signout + Invidious::Routing.get "/Captcha", Invidious::Routes::Login, :captcha # User preferences Invidious::Routing.get "/preferences", Invidious::Routes::PreferencesRoute, :show