mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-23 00:29:53 +05:30
Fix expire for prefs cookie
This commit is contained in:
parent
9239cfb3c1
commit
63be05146d
@ -1322,7 +1322,19 @@ post "/preferences" do |env|
|
|||||||
File.write("config/config.yml", config.to_yaml)
|
File.write("config/config.yml", config.to_yaml)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
env.response.cookies["PREFS"] = preferences
|
if Kemal.config.ssl || config.https_only
|
||||||
|
secure = true
|
||||||
|
else
|
||||||
|
secure = false
|
||||||
|
end
|
||||||
|
|
||||||
|
if config.domain
|
||||||
|
env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{config.domain}", value: preferences, expires: Time.now + 2.years,
|
||||||
|
secure: secure, http_only: true)
|
||||||
|
else
|
||||||
|
env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: preferences, expires: Time.now + 2.years,
|
||||||
|
secure: secure, http_only: true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
env.redirect referer
|
env.redirect referer
|
||||||
@ -1341,8 +1353,21 @@ get "/toggle_theme" do |env|
|
|||||||
else
|
else
|
||||||
preferences = env.get("preferences").as(Preferences)
|
preferences = env.get("preferences").as(Preferences)
|
||||||
preferences.dark_mode = !preferences.dark_mode
|
preferences.dark_mode = !preferences.dark_mode
|
||||||
|
preferences = preferences.to_json
|
||||||
|
|
||||||
env.response.cookies["PREFS"] = preferences.to_json
|
if Kemal.config.ssl || config.https_only
|
||||||
|
secure = true
|
||||||
|
else
|
||||||
|
secure = false
|
||||||
|
end
|
||||||
|
|
||||||
|
if config.domain
|
||||||
|
env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{config.domain}", value: preferences, expires: Time.now + 2.years,
|
||||||
|
secure: secure, http_only: true)
|
||||||
|
else
|
||||||
|
env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: preferences, expires: Time.now + 2.years,
|
||||||
|
secure: secure, http_only: true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
env.redirect referer
|
env.redirect referer
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<div class="pure-u-1-3">
|
<div class="pure-u-1-3">
|
||||||
<a href="/toggle_theme?referer=<%= env.get?("current_page") %>" class="pure-menu-heading">
|
<a href="/toggle_theme?referer=<%= env.get?("current_page") %>" class="pure-menu-heading">
|
||||||
<% if env.get?("preferences").try &.as(Preferences).dark_mode %>
|
<% if env.get("preferences").as(Preferences).dark_mode %>
|
||||||
<i class="icon ion-ios-sunny"></i>
|
<i class="icon ion-ios-sunny"></i>
|
||||||
<% else %>
|
<% else %>
|
||||||
<i class="icon ion-ios-moon"></i>
|
<i class="icon ion-ios-moon"></i>
|
||||||
|
Loading…
Reference in New Issue
Block a user