FIX: Prevent users from converting the default theme to a component

This results in some fun disasters if allowed to happen. For now, just issue an oblique error message; a localized message will be added on the client.
This commit is contained in:
Kane York
2021-01-11 14:53:04 -08:00
committed by Kane York
parent bd25627198
commit e96c373f3a
2 changed files with 14 additions and 0 deletions

View File

@ -401,8 +401,10 @@ class Admin::ThemesController < Admin::AdminController
def handle_switch
param = theme_params[:component]
if param.to_s == "false" && @theme.component?
raise Discourse::InvalidParameters.new(:component) if @theme.id == SiteSetting.default_theme_id
@theme.switch_to_theme!
elsif param.to_s == "true" && !@theme.component?
raise Discourse::InvalidParameters.new(:component) if @theme.id == SiteSetting.default_theme_id
@theme.switch_to_component!
end
end