Revert "FIX: preview theme not working consistently"

This reverts commit 845cec3ba0.
was not a needed change, but was elsewhere
This commit is contained in:
Sam 2018-02-23 17:59:00 +11:00
parent 6f076963f2
commit a94dc0c731
2 changed files with 3 additions and 13 deletions

View File

@ -5,14 +5,10 @@ class Admin::ThemesController < Admin::AdminController
skip_before_action :check_xhr, only: [:show, :preview]
def self.whitelist_theme_key(user)
"whitelist_theme_key_#{user.id}"
end
def preview
@theme = Theme.find(params[:id])
$redis.setex(Admin::ThemesController.whitelist_theme_key(current_user), 60, @theme.key)
redirect_to path("/?preview_theme_key=#{@theme.key}")
redirect_to path("/"), flash: { preview_theme_key: @theme.key }
end
def upload_asset

View File

@ -307,13 +307,7 @@ class ApplicationController < ActionController::Base
resolve_safe_mode
return if request.env[NO_CUSTOM]
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
theme_key = flash[:preview_theme_key]
user_option = current_user&.user_option