Reset local creds if access is denied (#9114)

This commit is contained in:
Keith Holliday
2017-09-30 23:15:24 -05:00
committed by GitHub
parent e87c180e9b
commit 1f895fda44
2 changed files with 18 additions and 5 deletions

View File

@@ -144,6 +144,16 @@ export default {
return response;
}, (error) => {
if (error.response.status >= 400) {
// Check for conditions to reset the user auth
const invalidUserMessage = [this.$t('invalidCredentials'), 'Missing authentication headers.'];
if (invalidUserMessage.indexOf(error.response.data.message) !== -1) {
localStorage.removeItem('habit-mobile-settings');
localStorage.removeItem('hello');
this.$store.state.isUserLoggedIn = false;
window.location.href = '/static/home';
return Promise.reject(error);
}
// Don't show errors from getting user details. These users have delete their account,
// but their chat message still exists.
let configExists = Boolean(error.response) && Boolean(error.response.config);