Skip to content

Commit

Permalink
bug: 优化op登录(太湖登录情况下,无cookie正常登录) #2441
Browse files Browse the repository at this point in the history
  • Loading branch information
lannoy0523 committed Jul 30, 2024
1 parent 6a37309 commit 4f319df
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/frontend/devops-op/src/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import { getBkUid, getToken } from '@/utils/auth' // get token from cookie
import { toLoginPage } from '@/utils/login'
import { MODE_CONFIG, MODE_CONFIG_STAND_ALONE, toLoginPage } from '@/utils/login'
import { ROLE_ADMIN } from '@/store/modules/user'
import { userInfo } from '@/api/user'

NProgress.configure({ showSpinner: false }) // NProgress Configuration

Expand All @@ -20,7 +21,7 @@ router.beforeEach(async(to, from, next) => {

// determine whether the user has logged in
// const bkTicket = getBkTicket()
const bkUid = getBkUid()
const bkUid = getBkUid() || store.getters.name
const token = getToken()
// const hasToken = token || bkTicket || bkUid
const hasToken = token || bkUid
Expand Down Expand Up @@ -71,6 +72,16 @@ router.beforeEach(async(to, from, next) => {
next()
} else {
// other pages that do not have permission to access are redirected to the login page.
if (MODE_CONFIG !== MODE_CONFIG_STAND_ALONE) {
try {
const response = await fetch(userInfo)
if (response.ok) {
await store.dispatch('user/getInfo')
}
} catch (error) {
console.error(error)
}
}
toLoginPage(to.path)
NProgress.done()
}
Expand Down

0 comments on commit 4f319df

Please sign in to comment.