Class: Spree::Admin::ThemeController

Inherits:
BaseController show all
Defined in:
app/controllers/spree/admin/theme_controller.rb

Instance Method Summary collapse

Methods included from SetsUserLanguageLocaleKey

#set_user_language_locale_key

Instance Method Details

#setObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/spree/admin/theme_controller.rb', line 8

def set
  requested_theme = params[:switch_to_theme].presence

  # Avoid interpolating user content into the session key
  system_theme = params[:system_theme].presence == "dark" ? "dark" : "light"
  session_key = :"admin_#{system_theme}_theme"

  if theme_is_available?(requested_theme)
    session[session_key] = requested_theme
    redirect_back_or_to spree.admin_url, notice: t('spree.theme_changed')
  else
    redirect_back_or_to spree.admin_url, error: t('spree.error')
  end
end