Compare commits

...

6 Commits

Author SHA1 Message Date
John Wong
01976c6c2d
Merge d3e6d7b6c5 into bad92093bf 2024-07-11 16:24:31 +01:00
kaka
d3e6d7b6c5 Set the cookie first 2023-07-15 08:49:18 +08:00
kaka
f5244055a2 @SamantazFox: Put that code before return if (on line 64) 2023-07-15 06:57:37 +08:00
John Wong
af86cdbd38
Merge branch 'iv-org:master' into master 2023-07-15 06:47:36 +08:00
John Wong
b3637f20a9 check the config flag first 2023-04-10 10:58:11 +08:00
John Wong
c676272604 login_only 2023-04-08 22:23:36 +08:00
2 changed files with 19 additions and 12 deletions

View File

@ -84,6 +84,7 @@ class Config
# Used to tell Invidious it is behind a proxy, so links to resources should be https://
property https_only : Bool?
property login_only : Bool?
# HMAC signing key for CSRF tokens and verifying pubsub subscriptions
property hmac_key : String = ""
# Domain to be used for links to resources on the site where an absolute URL is required

View File

@ -61,18 +61,6 @@ module Invidious::Routes::BeforeAll
env.response.headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains; preload"
end
return if {
"/sb/",
"/vi/",
"/s_p/",
"/yts/",
"/ggpht/",
"/api/manifest/",
"/videoplayback",
"/latest_version",
"/download",
}.any? { |r| env.request.resource.starts_with? r }
if env.request.cookies.has_key? "SID"
sid = env.request.cookies["SID"].value
@ -100,6 +88,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"