JSON API parsing error on CSRF exception: single quotes in ['BAD CSRF'] is invalid JSON:

https://meta.discourse.org/t/json-api-parsing-error-single-quotes-used-for-errors-like-bad-csrf/58869
This commit is contained in:
Victor van Poppelen 2017-03-16 16:47:18 -07:00
parent ad8a579c79
commit 9e60f9f093
2 changed files with 2 additions and 2 deletions

View File

@ -69,7 +69,7 @@ export function ajax() {
args.error = (xhr, textStatus, errorThrown) => {
// note: for bad CSRF we don't loop an extra request right away.
// this allows us to eliminate the possibility of having a loop.
if (xhr.status === 403 && xhr.responseText === "['BAD CSRF']") {
if (xhr.status === 403 && xhr.responseText === "[\"BAD CSRF\"]") {
Discourse.Session.current().set('csrfToken', null);
}

View File

@ -29,7 +29,7 @@ class ApplicationController < ActionController::Base
unless is_api? || is_user_api?
super
clear_current_user
render text: "['BAD CSRF']", status: 403
render text: "[\"BAD CSRF\"]", status: 403
end
end