This commit is contained in:
Gender Shrapnel 2024-04-01 20:28:19 +02:00
parent dde4119e50
commit a870906698

View File

@ -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