|
|
@@ -17,7 +17,7 @@ import GlobalMessage from '@/components/Basic/GlobalMessage'
|
|
|
import SlideUpTransition from '@/animations/SlideUpTransition'
|
|
|
import { mapState } from 'vuex'
|
|
|
import userType, { userTypeNaming } from '@/enums/user-type'
|
|
|
-// import { jumpToLogin } from '@/server/auth'
|
|
|
+import { jumpToLogin } from '@/server/auth'
|
|
|
import { SET_TOKEN, SET_USER_INFO } from '@/store/types/main-types'
|
|
|
import { getUserInfo } from '@/server/user'
|
|
|
|
|
|
@@ -47,7 +47,7 @@ export default {
|
|
|
}, (error) => {
|
|
|
if (error.response.status === 401 && this.$route.matched.some(record => record.meta.roles)) {
|
|
|
// this.$router.push({ name: 'login' })
|
|
|
- // jumpToLogin()
|
|
|
+ jumpToLogin()
|
|
|
}
|
|
|
return Promise.reject(error)
|
|
|
})
|
|
|
@@ -86,16 +86,18 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
fetchUserInfo () {
|
|
|
- setTimeout(() => {
|
|
|
- getUserInfo().then(res => {
|
|
|
- this.$store.commit(SET_USER_INFO, { userInfo: res })
|
|
|
+ getUserInfo().then(res => {
|
|
|
+ this.$store.commit(SET_USER_INFO, { userInfo: res })
|
|
|
+ if (this.$route.path === '/') {
|
|
|
if (res.role === userType.student) {
|
|
|
this.$router.push({ name: 'student-explore' })
|
|
|
} else {
|
|
|
this.$router.push({ name: 'teacher-explore' })
|
|
|
}
|
|
|
- }).catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
- }, 5000)
|
|
|
+ } else {
|
|
|
+ this.$router.push({ name: this.$route.name })
|
|
|
+ }
|
|
|
+ }).catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
}
|
|
|
}
|
|
|
}
|