Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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