Update session error notification handling to differentiate session time out from not having auth'ed

pull/1265/head
Jared Scheib 2017-04-12 12:22:46 -07:00
parent 30cc0af300
commit 869b7864a6
1 changed files with 10 additions and 5 deletions

View File

@ -108,15 +108,20 @@ const Root = React.createClass({
setTimeout(this.startHeartbeat.bind(null, {shouldDispatchResponse: false}), HEARTBEAT_INTERVAL)
} catch (error) {
if (error.status === HTTP_FORBIDDEN) {
const {auth: {me}} = store.getState()
if (me === null) {
dispatch(publishNotification('error', 'Please login to use Chronograf.'))
} else {
dispatch(publishNotification('error', 'Session timed out. Please login again.'))
}
} else {
dispatch(publishNotification('error', 'Cannot communicate with server.'))
}
if (error.auth) {
dispatch(authReceived(error.auth))
dispatch(meReceived(null))
}
if (error.status === HTTP_FORBIDDEN) {
dispatch(publishNotification('error', 'Session timed out. Please login again.'))
} else {
dispatch(publishNotification('error', 'Cannot communicate with server.'))
}
}
},