mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
[sql lab] allow users to save their queries (#2528)
* Allow users to save their queries Fixing tests . * Adding placeholder for Query Description * initJQueryCSRF -> initJQueryAjaxCSRF
This commit is contained in:
committed by
GitHub
parent
c1d9918abe
commit
122891c29b
@@ -196,3 +196,18 @@ export function getTextWidth(text, fontDetails) {
|
||||
const metrics = context.measureText(text);
|
||||
return metrics.width;
|
||||
}
|
||||
|
||||
export function initJQueryAjaxCSRF() {
|
||||
// Works in conjunction with a Flask-WTF token as described here:
|
||||
// http://flask-wtf.readthedocs.io/en/stable/csrf.html#javascript-requests
|
||||
const token = $('input#csrf_token').val();
|
||||
if (token) {
|
||||
$.ajaxSetup({
|
||||
beforeSend(xhr, settings) {
|
||||
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
|
||||
xhr.setRequestHeader('X-CSRFToken', token);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user