From a87090669870b835874dc14571a2f62919fbe7fb Mon Sep 17 00:00:00 2001 From: ModZero Date: Mon, 1 Apr 2024 20:28:19 +0200 Subject: [PATCH] Hm. --- src/invidious/routes/before_all.cr | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/invidious/routes/before_all.cr b/src/invidious/routes/before_all.cr index 4ee7282f..b9ce3f6c 100644 --- a/src/invidious/routes/before_all.cr +++ b/src/invidious/routes/before_all.cr @@ -100,6 +100,24 @@ module Invidious::Routes::BeforeAll end end + unregistered_path_whitelist = {"/", "/login", "/licenses", "/privacy"} + if CONFIG.login_only && !env.get?("user") && !unregistered_path_whitelist.includes?(env.request.path) + env.response.headers["Location"] = "/login" + haltf env, status_code: 302 + end + + return if { + "/sb/", + "/vi/", + "/s_p/", + "/yts/", + "/ggpht/", + "/api/manifest/", + "/videoplayback", + "/latest_version", + "/download", + }.any? { |r| env.request.resource.starts_with? r } + dark_mode = convert_theme(env.params.query["dark_mode"]?) || preferences.dark_mode.to_s thin_mode = env.params.query["thin_mode"]? || preferences.thin_mode.to_s thin_mode = thin_mode == "true" @@ -122,11 +140,5 @@ module Invidious::Routes::BeforeAll end env.set "current_page", URI.encode_www_form(current_page) - - unregistered_path_whitelist = {"/", "/login", "/licenses", "/privacy"} - if !env.get?("user") && !unregistered_path_whitelist.includes?(env.request.path) && CONFIG.login_only - env.response.headers["Location"] = "/login" - haltf env, status_code: 302 - end end end