FEATURE: Always disable customizations on the `/safe-mode` route (#9052)

This makes it easier to enter safe mode when a customization has made the UI unusable
This commit is contained in:
David Taylor 2020-02-28 10:53:11 +00:00 committed by GitHub
parent 8cbb6e35cb
commit 0903aa44bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -3,6 +3,7 @@
class SafeModeController < ApplicationController class SafeModeController < ApplicationController
layout 'no_ember' layout 'no_ember'
before_action :ensure_safe_mode_enabled before_action :ensure_safe_mode_enabled
before_action :force_safe_mode_for_route
skip_before_action :preload_json, :check_xhr skip_before_action :preload_json, :check_xhr
@ -29,4 +30,9 @@ class SafeModeController < ApplicationController
raise Discourse::NotFound unless guardian.can_enable_safe_mode? raise Discourse::NotFound unless guardian.can_enable_safe_mode?
end end
def force_safe_mode_for_route
request.env[ApplicationController::NO_CUSTOM] = true
request.env[ApplicationController::NO_PLUGINS] = true
end
end end

View File

@ -3,6 +3,18 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe SafeModeController do RSpec.describe SafeModeController do
describe 'index' do
it 'never includes customizations' do
theme = Fabricate(:theme)
theme.set_field(target: :common, name: "header", value: "My Custom Header")
theme.save!
theme.set_default!
get '/safe-mode'
expect(response.body).not_to include("My Custom Header")
end
end
describe 'enter' do describe 'enter' do
context 'when no params are given' do context 'when no params are given' do
it 'should redirect back to safe mode page' do it 'should redirect back to safe mode page' do