Merge c1877b3a4cf33c9688d9a0055def7f5cae615721 into fe2b6dbd67ef29bf3e0da6796f67623165c7b318

This commit is contained in:
Geekshere 2026-06-30 12:06:23 +04:00 committed by GitHub
commit 7733a1ff12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

@ -200,6 +200,25 @@ end
before_all do |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/",
}
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)}"
halt env, 302
end
end
end
Invidious::Routing.register_all

View File

@ -128,6 +128,8 @@ class Config
property popular_enabled : Bool = true
property captcha_enabled : Bool = true
property login_enabled : Bool = true
property require_login : Bool = false
property require_login_for_embeds : Bool = false
property registration_enabled : Bool = true
property statistics_enabled : Bool = false
property admins : Array(String) = [] of String