[bugfix] save dash fails with CSRF related error (#2552)

This commit is contained in:
Maxime Beauchemin 2017-04-05 12:01:17 -07:00 committed by GitHub
parent 337454b646
commit 2c04d3c250
4 changed files with 13 additions and 4 deletions

View File

@ -336,6 +336,7 @@ export function dashboardContainer(dashboard) {
$(document).ready(() => {
// Getting bootstrapped data from the DOM
utils.initJQueryAjaxCSRF();
const dashboardData = $('.dashboard').data('dashboard');
const contextData = $('.dashboard').data('context');

View File

@ -38,7 +38,12 @@
<div id="app" data-bootstrap="{{ bootstrap_data }}" >
<img src="/static/assets/images/loading.gif" style="width: 50px; margin: 10px;">
</div>
{{ csrf_token() if csrf_token else None }}
<input
type="hidden"
name="csrf_token"
id="csrf_token"
value="{{ csrf_token() if csrf_token else '' }}"
>
{% endblock %}
<!-- Modal for misc messages / alerts -->

View File

@ -22,4 +22,10 @@
<div id="grid-container" class="slice-grid gridster"></div>
</div>
<input
type="hidden"
name="csrf_token"
id="csrf_token"
value="{{ csrf_token() if csrf_token else '' }}"
>
{% endblock %}

View File

@ -2198,11 +2198,8 @@ class Superset(BaseSupersetView):
d = {
'defaultDbId': config.get('SQLLAB_DEFAULT_DBID'),
}
from flask_wtf import FlaskForm
ff = FlaskForm()
return self.render_template(
'superset/sqllab.html',
csrf_token=ff.csrf_token,
bootstrap_data=json.dumps(d, default=utils.json_iso_dttm_ser)
)
appbuilder.add_view_no_menu(Superset)