mirror of
https://github.com/iv-org/invidious.git
synced 2026-07-07 06:06:48 -05:00
Add require_login and require_login_for_embeds config options
This commit is contained in:
parent
c010be3e0c
commit
c1877b3a4c
@ -206,12 +206,15 @@ before_all do |env|
|
|||||||
path = env.request.path
|
path = env.request.path
|
||||||
allowed = {
|
allowed = {
|
||||||
"/login", "/register", "/api/",
|
"/login", "/register", "/api/",
|
||||||
"/embed/",
|
|
||||||
"/sb/", "/vi/", "/s_p/", "/yts/", "/ggpht/",
|
"/sb/", "/vi/", "/s_p/", "/yts/", "/ggpht/",
|
||||||
"/api/manifest/", "/videoplayback", "/latest_version",
|
"/api/manifest/", "/videoplayback", "/latest_version",
|
||||||
"/download", "/companion/",
|
"/download", "/companion/",
|
||||||
}
|
}
|
||||||
unless allowed.any? { |p| path.starts_with?(p) }
|
|
||||||
|
is_allowed = allowed.any? { |p| path.starts_with?(p) }
|
||||||
|
is_allowed ||= path.starts_with?("/embed/") && !CONFIG.require_login_for_embeds
|
||||||
|
|
||||||
|
unless is_allowed
|
||||||
env.redirect "/login?referer=#{URI.encode_www_form(path)}"
|
env.redirect "/login?referer=#{URI.encode_www_form(path)}"
|
||||||
halt env, 302
|
halt env, 302
|
||||||
end
|
end
|
||||||
|
|||||||
@ -129,6 +129,7 @@ class Config
|
|||||||
property captcha_enabled : Bool = true
|
property captcha_enabled : Bool = true
|
||||||
property login_enabled : Bool = true
|
property login_enabled : Bool = true
|
||||||
property require_login : Bool = false
|
property require_login : Bool = false
|
||||||
|
property require_login_for_embeds : Bool = false
|
||||||
property registration_enabled : Bool = true
|
property registration_enabled : Bool = true
|
||||||
property statistics_enabled : Bool = false
|
property statistics_enabled : Bool = false
|
||||||
property admins : Array(String) = [] of String
|
property admins : Array(String) = [] of String
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user