parent
8dae98a3f6
commit
6baea9948b
|
@ -167,6 +167,12 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
render_json_error I18n.t(opts[:custom_message] || type), type: type, status: status_code
|
||||
else
|
||||
begin
|
||||
current_user
|
||||
rescue Discourse::InvalidAccess
|
||||
return render plain: I18n.t(type), status: status_code
|
||||
end
|
||||
|
||||
render html: build_not_found_page(status_code, opts[:include_ember] ? 'application' : 'no_ember')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1059,12 +1059,14 @@ describe TopicsController do
|
|||
end
|
||||
|
||||
it 'returns 403 for an invalid key' do
|
||||
get :show, params: {
|
||||
topic_id: topic.id, slug: topic.slug, api_key: "bad"
|
||||
}, format: :json
|
||||
[:json, :html].each do |format|
|
||||
get :show, params: {
|
||||
topic_id: topic.id, slug: topic.slug, api_key: "bad"
|
||||
}, format: format
|
||||
|
||||
expect(response.code.to_i).to be(403)
|
||||
expect(response.body).to eq(I18n.t("invalid_access"))
|
||||
expect(response.code.to_i).to be(403)
|
||||
expect(response.body).to eq(I18n.t("invalid_access"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue