2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-07 12:02:53 +08:00

FEATURE: allow users to select theme on single device

This commit is contained in:
Sam 2017-05-15 12:48:08 -04:00
parent a0c936dadb
commit e1dd543a93
11 changed files with 97 additions and 17 deletions

View file

@ -267,13 +267,19 @@ class ApplicationController < ActionController::Base
resolve_safe_mode
return if request.env[NO_CUSTOM]
theme_key = flash[:preview_theme_key] || current_user&.user_option&.theme_key
theme_key = flash[:preview_theme_key]
# TODO 2018: delete this, old cookie cleanup code
if cookies[:theme_key]
cookies.delete(:theme_key)
user_option = current_user&.user_option
unless theme_key
key, seq = cookies[:theme_key]&.split(",")
if key && seq && seq.to_i == user_option&.theme_key_seq
theme_key = key
end
end
theme_key ||= user_option&.theme_key
if theme_key && !guardian.allow_theme?(theme_key)
theme_key = nil
end