FIX: Make read only errors respect the request format (#16741)

This commit is contained in:
Daniel Waterworth 2022-05-12 17:04:49 -05:00 committed by GitHub
parent 18ebe2fc28
commit 1d7e423f86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -246,8 +246,15 @@ class ApplicationController < ActionController::Base
rescue_from Discourse::ReadOnly do rescue_from Discourse::ReadOnly do
unless response_body unless response_body
respond_to do |format|
format.json do
render_json_error I18n.t('read_only_mode_enabled'), type: :read_only, status: 503 render_json_error I18n.t('read_only_mode_enabled'), type: :read_only, status: 503
end end
format.html do
render status: 503, layout: 'no_ember', template: 'exceptions/read_only'
end
end
end
end end
rescue_from SecondFactor::AuthManager::SecondFactorRequired do |e| rescue_from SecondFactor::AuthManager::SecondFactorRequired do |e|

View File

@ -0,0 +1 @@
<p><%= t('read_only_mode_enabled') %></p>