FIX: preview theme not working consistently

Avoid flash, this makes debugging much simpler as well.

Additionally URL now clearly shows you are previewing a theme.
This commit is contained in:
Sam
2018-02-23 14:33:27 +11:00
parent 4ac5fc8cd3
commit 845cec3ba0
2 changed files with 13 additions and 3 deletions

View File

@ -307,7 +307,13 @@ class ApplicationController < ActionController::Base
resolve_safe_mode
return if request.env[NO_CUSTOM]
theme_key = flash[:preview_theme_key]
theme_key = nil
if (k = request[:preview_theme_key]) && current_user
# some extra security, only to use the magic param the key needs to be whitelisted
if k == $redis.get(::Admin::ThemesController.whitelist_theme_key(current_user))
theme_key = k
end
end
user_option = current_user&.user_option