Revert "Revert "Log out user if organization is gone on the server""
This reverts commit 6fef259625
.
pull/2399/head
parent
4b3a239b74
commit
94e94d3aa9
|
@ -81,8 +81,8 @@ export const getMeAsync = ({shouldResetMe = false} = {}) => async dispatch => {
|
|||
)
|
||||
dispatch(linksReceived({external, users, organizations, me: meLink})) // TODO: put this before meGetCompleted... though for some reason it doesn't fire the first time then
|
||||
} catch (error) {
|
||||
dispatch(errorThrown(error))
|
||||
dispatch(meGetFailed())
|
||||
dispatch(errorThrown(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,27 @@ const errorsMiddleware = store => next => action => {
|
|||
const {auth: {me}} = store.getState()
|
||||
|
||||
if (action.type === 'ERROR_THROWN') {
|
||||
const {error: {status, auth}, altText, alertType = 'error'} = action
|
||||
const {
|
||||
error: {status, auth, data: {message}},
|
||||
altText,
|
||||
alertType = 'error',
|
||||
} = action
|
||||
|
||||
if (status === HTTP_FORBIDDEN) {
|
||||
const organizationChanged =
|
||||
message === `user's current organization was not found` // eslint-disable-line quotes
|
||||
const wasSessionTimeout = me !== null
|
||||
|
||||
store.dispatch(authExpired(auth))
|
||||
|
||||
if (wasSessionTimeout) {
|
||||
if (organizationChanged) {
|
||||
store.dispatch(notify(alertType, 'Your organization has been removed.'))
|
||||
|
||||
allowNotifications = false
|
||||
setTimeout(() => {
|
||||
allowNotifications = true
|
||||
}, notificationsBlackoutDuration)
|
||||
} else if (wasSessionTimeout) {
|
||||
store.dispatch(
|
||||
notify(alertType, 'Session timed out. Please login again.')
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue