diff --git a/ui/src/shared/actions/auth.js b/ui/src/shared/actions/auth.js index 5c0547606..bacb95506 100644 --- a/ui/src/shared/actions/auth.js +++ b/ui/src/shared/actions/auth.js @@ -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)) } } diff --git a/ui/src/shared/middleware/errors.js b/ui/src/shared/middleware/errors.js index 73c0e6102..6cf05ff5a 100644 --- a/ui/src/shared/middleware/errors.js +++ b/ui/src/shared/middleware/errors.js @@ -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.') )