Set preferences before conditional breaks in before_all (#1412)

This commit is contained in:
Matthew McGarvey 2020-10-16 05:23:18 -05:00 committed by GitHub
parent 0f643daac6
commit d571573e52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -246,12 +246,13 @@ spawn do
end
before_all do |env|
begin
preferences = Preferences.from_json(env.request.cookies["PREFS"]?.try &.value || "{}")
preferences = begin
Preferences.from_json(env.request.cookies["PREFS"]?.try &.value || "{}")
rescue
preferences = Preferences.from_json("{}")
Preferences.from_json("{}")
end
env.set "preferences", preferences
env.response.headers["X-XSS-Protection"] = "1; mode=block"
env.response.headers["X-Content-Type-Options"] = "nosniff"
extra_media_csp = ""
@ -298,6 +299,7 @@ before_all do |env|
}, HMAC_KEY, PG_DB, 1.week)
preferences = user.preferences
env.set "preferences", preferences
env.set "sid", sid
env.set "csrf_token", csrf_token
@ -319,6 +321,7 @@ before_all do |env|
}, HMAC_KEY, PG_DB, 1.week)
preferences = user.preferences
env.set "preferences", preferences
env.set "sid", sid
env.set "csrf_token", csrf_token
@ -336,7 +339,6 @@ before_all do |env|
preferences.dark_mode = dark_mode
preferences.thin_mode = thin_mode
preferences.locale = locale
env.set "preferences", preferences
current_page = env.request.path
if env.request.query