Fixes reload of page on session expiry (#658)

Co-authored-by: Pearl Dsilva <pearl.dsilva@shapeblue.com>
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Pearl Dsilva 2020-09-16 14:48:38 +05:30 committed by Rohit Yadav
parent 60562b5f54
commit 60551aeac2
3 changed files with 18 additions and 6 deletions

View File

@ -18,11 +18,11 @@
import Vue from 'vue'
import axios from 'axios'
import router from '@/router'
import store from '@/store'
import { VueAxios } from './axios'
import notification from 'ant-design-vue/es/notification'
import { CURRENT_PROJECT } from '@/store/mutation-types'
import i18n from '@/locales'
import store from '@/store'
const service = axios.create({
timeout: 600000
@ -46,9 +46,7 @@ const err = (error) => {
key: 'http-401'
})
store.dispatch('Logout').then(() => {
setTimeout(() => {
window.location.reload()
}, 1500)
router.go(0)
})
}
if (response.status === 404) {

View File

@ -653,9 +653,16 @@ export default {
return
}
if ([401].includes(error.response.status)) {
store.dispatch('Logout').then(() => {
this.$router.push({ path: '/user/login', query: { redirect: this.$route.fullPath } })
})
return
}
this.$notifyError(error)
if ([401, 405].includes(error.response.status)) {
if ([405].includes(error.response.status)) {
this.$router.push({ path: '/exception/403' })
}

View File

@ -181,7 +181,14 @@ export default {
duration: 0
})
if ([401, 405].includes(error.response.status)) {
if ([401].includes(error.response.status)) {
store.dispatch('Logout').then(() => {
this.$router.push({ path: '/user/login', query: { redirect: this.$route.fullPath } })
})
return
}
if ([405].includes(error.response.status)) {
this.$router.push({ path: '/exception/403' })
}