Skip to content

Commit

Permalink
ui: Fix the problem with token expiration
Browse files Browse the repository at this point in the history
This resolve problem when token expired and not redirect to login in
first moment. Use the await in router, because without watch the
redundancy redirect with login.
  • Loading branch information
leonardojoao authored and gustavosbarreto committed Aug 19, 2020
1 parent 0044fad commit 004d688
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ui/src/store/helpers/http.js
@@ -1,4 +1,5 @@
import Axios from 'axios';
import router from '@/router/index';
import store from '..';

export default () => {
Expand All @@ -11,9 +12,10 @@ export default () => {

axios.interceptors.response.use(
(response) => response,
(error) => {
async (error) => {
if (error.response.status === 401) {
store.dispatch('auth/logout');
await store.dispatch('auth/logout');
await router.push({ name: 'login' });
}
throw error;
},
Expand Down

0 comments on commit 004d688

Please sign in to comment.