mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: csrf token only on non-GET routes
This commit is contained in:
@@ -10,11 +10,7 @@ define('api', () => {
|
||||
baseUrl + options.url;
|
||||
|
||||
function doAjax(cb) {
|
||||
$.ajax(Object.assign({
|
||||
headers: {
|
||||
'x-csrf-token': config.csrf_token,
|
||||
},
|
||||
}, options))
|
||||
$.ajax(options)
|
||||
.done((res) => {
|
||||
cb(null,
|
||||
res.hasOwnProperty('status') && res.hasOwnProperty('response') ?
|
||||
@@ -57,18 +53,27 @@ define('api', () => {
|
||||
url: route,
|
||||
method: 'post',
|
||||
data: payload,
|
||||
headers: {
|
||||
'x-csrf-token': config.csrf_token,
|
||||
},
|
||||
}, onSuccess);
|
||||
|
||||
api.put = (route, payload, onSuccess) => call({
|
||||
url: route,
|
||||
method: 'put',
|
||||
data: payload,
|
||||
headers: {
|
||||
'x-csrf-token': config.csrf_token,
|
||||
},
|
||||
}, onSuccess);
|
||||
|
||||
api.del = (route, payload, onSuccess) => call({
|
||||
url: route,
|
||||
method: 'delete',
|
||||
data: payload,
|
||||
headers: {
|
||||
'x-csrf-token': config.csrf_token,
|
||||
},
|
||||
}, onSuccess);
|
||||
|
||||
return api;
|
||||
|
||||
Reference in New Issue
Block a user