mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
improve csrf expiration error handling (#2695)
* add message * re run query on result set mount if there is session time out error
This commit is contained in:
committed by
Maxime Beauchemin
parent
5fd0e7d028
commit
2d5beb1f91
@@ -151,6 +151,9 @@ export function runQuery(query) {
|
|||||||
} else if (msg === null) {
|
} else if (msg === null) {
|
||||||
msg = `[${textStatus}] ${errorThrown}`;
|
msg = `[${textStatus}] ${errorThrown}`;
|
||||||
}
|
}
|
||||||
|
if (msg.indexOf('The CSRF token is missing') > 0) {
|
||||||
|
msg = 'Your session timed out, please refresh your page and try again.';
|
||||||
|
}
|
||||||
dispatch(queryFailed(query, msg));
|
dispatch(queryFailed(query, msg));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ export default class ResultSet extends React.PureComponent {
|
|||||||
height: props.search ? props.height - RESULT_SET_CONTROLS_HEIGHT : props.height,
|
height: props.search ? props.height - RESULT_SET_CONTROLS_HEIGHT : props.height,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
componentDidMount() {
|
||||||
|
// only do this the first time the component is rendered/mounted
|
||||||
|
this.reRunQueryIfSessionTimeoutErrorOnMount();
|
||||||
|
}
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
// when new results comes in, save them locally and clear in store
|
// when new results comes in, save them locally and clear in store
|
||||||
if (this.props.cache && (!nextProps.query.cached)
|
if (this.props.cache && (!nextProps.query.cached)
|
||||||
@@ -53,7 +57,6 @@ export default class ResultSet extends React.PureComponent {
|
|||||||
this.fetchResults(nextProps.query);
|
this.fetchResults(nextProps.query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getControls() {
|
getControls() {
|
||||||
if (this.props.search || this.props.visualize || this.props.csv) {
|
if (this.props.search || this.props.visualize || this.props.csv) {
|
||||||
let csvButton;
|
let csvButton;
|
||||||
@@ -132,7 +135,12 @@ export default class ResultSet extends React.PureComponent {
|
|||||||
reFetchQueryResults(query) {
|
reFetchQueryResults(query) {
|
||||||
this.props.actions.reFetchQueryResults(query);
|
this.props.actions.reFetchQueryResults(query);
|
||||||
}
|
}
|
||||||
|
reRunQueryIfSessionTimeoutErrorOnMount() {
|
||||||
|
const { query } = this.props;
|
||||||
|
if (query.errorMessage && query.errorMessage.indexOf('session timed out') > 0) {
|
||||||
|
this.props.actions.runQuery(query, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
const query = this.props.query;
|
const query = this.props.query;
|
||||||
const results = query.results;
|
const results = query.results;
|
||||||
|
|||||||
Reference in New Issue
Block a user