mirror of
https://github.com/discourse/discourse.git
synced 2025-03-28 06:45:37 +08:00
Revert "FIX: preview theme not working consistently"
This reverts commit 845cec3ba02276cc704ba69c01ad75f8eb22df75. was not a needed change, but was elsewhere
This commit is contained in:
parent
6f076963f2
commit
a94dc0c731
@ -5,14 +5,10 @@ class Admin::ThemesController < Admin::AdminController
|
|||||||
|
|
||||||
skip_before_action :check_xhr, only: [:show, :preview]
|
skip_before_action :check_xhr, only: [:show, :preview]
|
||||||
|
|
||||||
def self.whitelist_theme_key(user)
|
|
||||||
"whitelist_theme_key_#{user.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def preview
|
def preview
|
||||||
@theme = Theme.find(params[:id])
|
@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
|
end
|
||||||
|
|
||||||
def upload_asset
|
def upload_asset
|
||||||
|
@ -307,13 +307,7 @@ class ApplicationController < ActionController::Base
|
|||||||
resolve_safe_mode
|
resolve_safe_mode
|
||||||
return if request.env[NO_CUSTOM]
|
return if request.env[NO_CUSTOM]
|
||||||
|
|
||||||
theme_key = nil
|
theme_key = flash[:preview_theme_key]
|
||||||
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
|
user_option = current_user&.user_option
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user