2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-20 23:46:02 -06:00
|
|
|
class SafeModeController < ApplicationController
|
|
|
|
layout "no_ember"
|
2018-04-23 13:50:52 -05:00
|
|
|
before_action :ensure_safe_mode_enabled
|
2020-02-28 04:53:11 -06:00
|
|
|
before_action :force_safe_mode_for_route
|
2018-04-23 13:50:52 -05:00
|
|
|
|
2017-08-30 23:06:56 -05:00
|
|
|
skip_before_action :preload_json, :check_xhr
|
2016-11-20 23:46:02 -06:00
|
|
|
|
|
|
|
def index
|
|
|
|
end
|
|
|
|
|
|
|
|
def enter
|
|
|
|
safe_mode = []
|
2022-08-15 09:15:15 -05:00
|
|
|
|
|
|
|
safe_mode << "no_themes" if params["no_themes"] == "true"
|
|
|
|
|
|
|
|
if params["no_plugins"] == "true"
|
|
|
|
safe_mode << "no_plugins"
|
|
|
|
elsif params["no_unofficial_plugins"] == "true"
|
|
|
|
safe_mode << "no_unofficial_plugins"
|
2023-12-13 08:06:59 -06:00
|
|
|
elsif params["deprecation_errors"] == "true"
|
|
|
|
safe_mode << "deprecation_errors"
|
2022-08-15 09:15:15 -05:00
|
|
|
end
|
2016-11-20 23:46:02 -06:00
|
|
|
|
|
|
|
if safe_mode.length > 0
|
2022-08-15 09:15:15 -05:00
|
|
|
redirect_to path("/?safe_mode=#{safe_mode.join(",")}")
|
2016-11-20 23:46:02 -06:00
|
|
|
else
|
2017-11-12 22:59:51 -06:00
|
|
|
flash[:must_select] = true
|
2016-12-19 04:12:15 -06:00
|
|
|
redirect_to safe_mode_path
|
2016-11-20 23:46:02 -06:00
|
|
|
end
|
|
|
|
end
|
2018-04-23 13:50:52 -05:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def ensure_safe_mode_enabled
|
2018-04-25 10:46:54 -05:00
|
|
|
raise Discourse::NotFound unless guardian.can_enable_safe_mode?
|
2018-04-23 13:50:52 -05:00
|
|
|
end
|
|
|
|
|
2020-02-28 04:53:11 -06:00
|
|
|
def force_safe_mode_for_route
|
2022-08-15 09:15:15 -05:00
|
|
|
request.env[ApplicationController::NO_THEMES] = true
|
2020-02-28 04:53:11 -06:00
|
|
|
request.env[ApplicationController::NO_PLUGINS] = true
|
|
|
|
end
|
2016-11-20 23:46:02 -06:00
|
|
|
end
|