Skip to content

Commit

Permalink
Merge pull request #152 from alerta/delete-invalid-tokens
Browse files Browse the repository at this point in the history
Delete invalid auth tokens and log user out
  • Loading branch information
satterly authored Apr 24, 2019
2 parents 9e2d89a + 3f730f4 commit f9567a3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/services/api/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export function makeInterceptors(router) {
// redirect to login if API rejects auth token
redirectToLogin(error) {
if (error.response && error.response.status === 401) {
if (store.getters['auth/isLoggedIn']) {
store.dispatch('auth/logout')
}
if (router.currentRoute.path != '/login') {
router.replace({
path: '/login',
Expand Down

0 comments on commit f9567a3

Please sign in to comment.