mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 21:41:03 +08:00
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:
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user