Merge pull request #4763 from vvanpo/fork-master

JSON API parsing error on CSRF exception: single quotes in ['BAD CSRF'] is invalid JSON
This commit is contained in:
Régis Hanol 2017-03-17 09:19:10 +01:00 committed by GitHub
commit e600dca268
2 changed files with 2 additions and 2 deletions

View File

@ -69,7 +69,7 @@ export function ajax() {
args.error = (xhr, textStatus, errorThrown) => { args.error = (xhr, textStatus, errorThrown) => {
// note: for bad CSRF we don't loop an extra request right away. // note: for bad CSRF we don't loop an extra request right away.
// this allows us to eliminate the possibility of having a loop. // 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); Discourse.Session.current().set('csrfToken', null);
} }

View File

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