Skip to content

Commit

Permalink
[bugfix] save dash fails with CSRF related error (#2552)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 5, 2017
1 parent 337454b commit 2c04d3c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions superset/assets/javascripts/dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
7 changes: 6 additions & 1 deletion superset/templates/superset/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
6 changes: 6 additions & 0 deletions superset/templates/superset/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
3 changes: 0 additions & 3 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2198,11 +2198,8 @@ def sqllab(self):
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)
Expand Down

0 comments on commit 2c04d3c

Please sign in to comment.