mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-29 19:11:23 +00:00
Config: Support for alternative domains
This commit is contained in:
@@ -60,7 +60,13 @@ module Invidious::Routes::Login
|
||||
sid = Base64.urlsafe_encode(Random::Secure.random_bytes(32))
|
||||
Invidious::Database::SessionIDs.insert(sid, email)
|
||||
|
||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid)
|
||||
# Checks if there is any alternative domain, like a second domain name,
|
||||
# TOR or I2P address
|
||||
if alt = CONFIG.alternative_domains.index(env.request.headers["Host"])
|
||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.alternative_domains[alt], sid)
|
||||
else
|
||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid)
|
||||
end
|
||||
else
|
||||
return error_template(401, "Wrong username or password")
|
||||
end
|
||||
@@ -160,7 +166,13 @@ module Invidious::Routes::Login
|
||||
Invidious::Database::Users.insert(user)
|
||||
Invidious::Database::SessionIDs.insert(sid, email)
|
||||
|
||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid)
|
||||
# Checks if there is any alternative domain, like a second domain name,
|
||||
# TOR or I2P address
|
||||
if alt = CONFIG.alternative_domains.index(env.request.headers["Host"])
|
||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.alternative_domains[alt], sid)
|
||||
else
|
||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid)
|
||||
end
|
||||
|
||||
if env.request.cookies["PREFS"]?
|
||||
user.preferences = env.get("preferences").as(Preferences)
|
||||
|
||||
@@ -219,7 +219,13 @@ module Invidious::Routes::PreferencesRoute
|
||||
File.write("config/config.yml", CONFIG.to_yaml)
|
||||
end
|
||||
else
|
||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.domain, preferences)
|
||||
# Checks if there is any alternative domain, like a second domain name,
|
||||
# TOR or I2P address
|
||||
if alt = CONFIG.alternative_domains.index(env.request.headers["Host"])
|
||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.alternative_domains[alt], preferences)
|
||||
else
|
||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.domain, preferences)
|
||||
end
|
||||
end
|
||||
|
||||
env.redirect referer
|
||||
@@ -254,7 +260,13 @@ module Invidious::Routes::PreferencesRoute
|
||||
preferences.dark_mode = "dark"
|
||||
end
|
||||
|
||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.domain, preferences)
|
||||
# Checks if there is any alternative domain, like a second domain name,
|
||||
# TOR or I2P address
|
||||
if alt = CONFIG.alternative_domains.index(env.request.headers["Host"])
|
||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.alternative_domains[alt], preferences)
|
||||
else
|
||||
env.response.cookies["PREFS"] = Invidious::User::Cookies.prefs(CONFIG.domain, preferences)
|
||||
end
|
||||
end
|
||||
|
||||
if redirect
|
||||
|
||||
Reference in New Issue
Block a user