Skip to content

Commit

Permalink
Merge pull request #158 from saltastro/logout-user
Browse files Browse the repository at this point in the history
Logout user when unauthorised
  • Loading branch information
hettlage authored Oct 13, 2020
2 parents a8b662b + c23bd18 commit eb11d6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const graphqlClient = () => ({
throw new Error(res.data.errors.map(error => error.message).join(' | '))
}
return res
}).catch(error => {
if (error.response.status === 401){
localStorage.removeItem('tacPageJWT')
}
})
}
})
Expand All @@ -75,7 +79,11 @@ export const saltServerApiClient = () => (
throw new Error(response.data.errors.map(error => error.message).join(' | '))
}
return response
})
}).catch(error => {
if (error.response.status === 401){
localStorage.removeItem('tacPageJWT')
}
})
}
}
)
Expand Down
2 changes: 2 additions & 0 deletions src/components/messages/FailToLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const FailToLoad = () => (
</div>
<div>
<h2>Oops. Data download failed.</h2>
<h2>Please refresh the page and, if necessary, login again. </h2>
<h2>If this message persists please contact SALT help.</h2>
</div>
</div>
</div>
Expand Down

0 comments on commit eb11d6b

Please sign in to comment.