mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
33 lines
750 B
Ruby
33 lines
750 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SafeModeController < ApplicationController
|
|
layout 'no_ember'
|
|
before_action :ensure_safe_mode_enabled
|
|
|
|
skip_before_action :preload_json, :check_xhr
|
|
|
|
def index
|
|
end
|
|
|
|
def enter
|
|
safe_mode = []
|
|
safe_mode << "no_custom" if params["no_customizations"] == "true"
|
|
safe_mode << "no_plugins" if params["no_plugins"] == "true"
|
|
safe_mode << "only_official" if params["only_official"] == "true"
|
|
|
|
if safe_mode.length > 0
|
|
redirect_to path("/?safe_mode=#{safe_mode.join("%2C")}")
|
|
else
|
|
flash[:must_select] = true
|
|
redirect_to safe_mode_path
|
|
end
|
|
end
|
|
|
|
protected
|
|
|
|
def ensure_safe_mode_enabled
|
|
raise Discourse::NotFound unless guardian.can_enable_safe_mode?
|
|
end
|
|
|
|
end
|