Skip to content
Permalink
Browse files
Navigate to login page When auth token failed (#683)
fix #682
  • Loading branch information
tzr164 committed Jan 26, 2021
1 parent 24e7f33 commit 8df509bfd39960cd1e6888c71e7bd29f526aacac
Showing 6 changed files with 18 additions and 12 deletions.
@@ -47,7 +47,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
if (null != authority && authority.needLogin()) {
String authorization = request.getHeader("Authorization");
UserController.User user = UserController.tokenMap.get(authorization);
if (null != user && System.currentTimeMillis() - user.getLastUpdateTime() <= 1000 * 60 * 15) {
if (null != user && System.currentTimeMillis() - user.getLastUpdateTime() <= 1000 * 60 * 60) {
user.setLastUpdateTime(System.currentTimeMillis());
return true;
}
@@ -17,6 +17,8 @@
import axios from 'axios'
import Vue from 'vue'
import HttpStatus from 'http-status'
import router from '@/router'
import i18n from '@/lang'

let instance = axios.create({
baseURL: '/api/dev'
@@ -38,7 +40,8 @@ instance.interceptors.response.use((response) => {
} else if (error.response.status === HttpStatus.UNAUTHORIZED) {
localStorage.removeItem('token')
localStorage.removeItem('username')
Vue.prototype.$notify.error('Authorized failed,please login.')
Vue.prototype.$notify.error(i18n.t('authFailed'))
router.push({ path: 'login' })
} else if (error.response.status >= HttpStatus.BAD_REQUEST) {
Vue.prototype.$notify.error(error.response.data.message)
}
@@ -195,5 +195,6 @@ export default {
unsupportedHtmlTypeTip: 'Temporarily unsupported form type',
none: 'none'
}
}
},
authFailed:'Authorized failed,please login.'
}
@@ -195,5 +195,6 @@ export default {
unsupportedHtmlTypeTip: '暂不支持的表单类型',
none: '无'
}
}
},
authFailed:'权限验证失败'
}
@@ -47,14 +47,6 @@ VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard)
Vue.component('chart', ECharts)

/* eslint-disable no-new */
new Vue({
router,
store,
i18n,
render: h => h(App)
}).$mount('#app')

router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requireLogin)) {
if (localStorage.getItem('token')) {
@@ -69,3 +61,11 @@ router.beforeEach((to, from, next) => {
next()
}
})

/* eslint-disable no-new */
new Vue({
router,
store,
i18n,
render: h => h(App)
}).$mount('#app')
@@ -39,6 +39,7 @@ module.exports = {
}
},
configureWebpack: {
devtool: process.env.NODE_ENV === 'dev' ? 'source-map' : undefined,
performance: {
hints: false
},

0 comments on commit 8df509b

Please sign in to comment.