FIX: Display json response when Discourse::InvalidAccess is raised for

non json requests.
This commit is contained in:
Guo Xiang Tan
2017-09-28 15:29:57 +08:00
parent 373fd8990e
commit 5f1c29e424
2 changed files with 10 additions and 1 deletions

View File

@ -157,7 +157,8 @@ class ApplicationController < ActionController::Base
opts ||= {}
show_json_errors = (request.format && request.format.json?) ||
(request.xhr?) ||
((params[:external_id] || '').ends_with? '.json')
((params[:external_id] || '').ends_with? '.json') ||
!(current_user rescue nil)
if show_json_errors
# HACK: do not use render_json_error for topics#show