mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-17 23:59:02 +00:00
[update]校验登录状态
This commit is contained in:
@@ -77,7 +77,7 @@ router.beforeEach(async(to, from, next) => {
|
||||
// remove token and go to login page to re-login
|
||||
// await store.dispatch('user/resetToken')
|
||||
Message.error(error || 'Has Error')
|
||||
// next(`/login?redirect=${to.path}`)
|
||||
next(`/auth/login/`)
|
||||
console.log(error)
|
||||
NProgress.done()
|
||||
// next()
|
||||
|
@@ -11,7 +11,8 @@ const getDefaultState = () => {
|
||||
token: getToken(),
|
||||
profile: {},
|
||||
currentOrg: getCurrentOrg(),
|
||||
orgs: []
|
||||
orgs: [],
|
||||
internalInit: Boolean
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +28,9 @@ const mutations = {
|
||||
SET_PROFILE: (state, profile) => {
|
||||
state.profile = profile
|
||||
},
|
||||
SET_STATUS: (state) => {
|
||||
state.internalInit = true
|
||||
},
|
||||
SET_ORGS: (state, orgs) => {
|
||||
// API BUG FIX
|
||||
for (let index = 0; index < orgs.length; index++) {
|
||||
@@ -61,18 +65,23 @@ const actions = {
|
||||
// get user Profile
|
||||
getProfile({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!state.internalInit) {
|
||||
reject('Init failed, please Login again.')
|
||||
}
|
||||
getProfile().then(response => {
|
||||
if (!response) {
|
||||
reject('Verification failed, please Login again.')
|
||||
}
|
||||
const { admin_or_audit_orgs } = response
|
||||
// const rules = [role]
|
||||
const { admin_or_audit_orgs, rule } = response
|
||||
const rules = [rule]
|
||||
// roles must be a non-empty array
|
||||
// if (!rules || rules.length <= 0) {
|
||||
// reject('getProfile: roles must be a non-null array!')
|
||||
// }
|
||||
if (!rules || rules.length <= 0) {
|
||||
reject('getProfile: roles must be a non-null array!')
|
||||
}
|
||||
|
||||
commit('SET_PROFILE', response)
|
||||
commit('SET_ORGS', admin_or_audit_orgs)
|
||||
commit('SET_STATUS')
|
||||
resolve(response)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
|
Reference in New Issue
Block a user