DEV: New readonly mode. Only applies to non-staff (#16243)

This commit is contained in:
Daniel Waterworth
2022-05-17 13:06:08 -05:00
committed by GitHub
parent 985afe1092
commit 6e53f4d913
14 changed files with 228 additions and 27 deletions

View File

@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
include JsonError
include GlobalPath
include Hijack
include ReadOnlyHeader
include ReadOnlyMixin
include VaryHeader
attr_reader :theme_id
@ -631,6 +631,7 @@ class ApplicationController < ActionController::Base
store_preloaded("banner", banner_json)
store_preloaded("customEmoji", custom_emoji)
store_preloaded("isReadOnly", @readonly_mode.to_s)
store_preloaded("isStaffWritesOnly", @staff_writes_only_mode.to_s)
store_preloaded("activatedThemes", activated_themes_json)
end
@ -876,11 +877,6 @@ class ApplicationController < ActionController::Base
!disqualified_from_2fa_enforcement && enforcing_2fa && !current_user.has_any_second_factor_methods_enabled?
end
def block_if_readonly_mode
return if request.fullpath.start_with?(path "/admin/backups")
raise Discourse::ReadOnly.new if !(request.get? || request.head?) && @readonly_mode
end
def build_not_found_page(opts = {})
if SiteSetting.bootstrap_error_pages?
preload_json