mirror of
https://github.com/iv-org/invidious.git
synced 2026-07-07 14:16:45 -05:00
Add require_login config option to redirect unauthenticated users
This commit is contained in:
parent
fe2b6dbd67
commit
625d128645
@ -200,6 +200,21 @@ end
|
|||||||
|
|
||||||
before_all do |env|
|
before_all do |env|
|
||||||
Invidious::Routes::BeforeAll.handle(env)
|
Invidious::Routes::BeforeAll.handle(env)
|
||||||
|
|
||||||
|
# Redirect unauthenticated users if require_login is enabled
|
||||||
|
if CONFIG.require_login && env.get?("user").nil?
|
||||||
|
path = env.request.path
|
||||||
|
allowed = {
|
||||||
|
"/login", "/register", "/api/",
|
||||||
|
"/sb/", "/vi/", "/s_p/", "/yts/", "/ggpht/",
|
||||||
|
"/api/manifest/", "/videoplayback", "/latest_version",
|
||||||
|
"/download", "/companion/",
|
||||||
|
}
|
||||||
|
unless allowed.any? { |p| path.starts_with?(p) }
|
||||||
|
env.redirect "/login?return_path=#{URI.encode_www_form(path)}"
|
||||||
|
halt env, 302
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Invidious::Routing.register_all
|
Invidious::Routing.register_all
|
||||||
|
|||||||
@ -128,6 +128,7 @@ class Config
|
|||||||
property popular_enabled : Bool = true
|
property popular_enabled : Bool = true
|
||||||
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 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