mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-06 06:09:05 +08:00
[Fix][UI-Next][V1.0.0-Alpha] Fix user login error (#8773)
* fix user login error * logout clear cookie
This commit is contained in:
parent
1d1c99b31f
commit
59410af0ae
@ -21,6 +21,7 @@ import { useUserStore } from '@/store/user/user'
|
|||||||
import { useMenuStore } from '@/store/menu/menu'
|
import { useMenuStore } from '@/store/menu/menu'
|
||||||
import type { Router } from 'vue-router'
|
import type { Router } from 'vue-router'
|
||||||
import { DropdownOption } from 'naive-ui'
|
import { DropdownOption } from 'naive-ui'
|
||||||
|
import cookies from 'js-cookie'
|
||||||
|
|
||||||
export function useDropDown() {
|
export function useDropDown() {
|
||||||
const router: Router = useRouter()
|
const router: Router = useRouter()
|
||||||
@ -41,6 +42,8 @@ export function useDropDown() {
|
|||||||
logout().then(() => {
|
logout().then(() => {
|
||||||
userStore.setSessionId('')
|
userStore.setSessionId('')
|
||||||
userStore.setUserInfo({})
|
userStore.setUserInfo({})
|
||||||
|
cookies.remove('sessionId')
|
||||||
|
|
||||||
router.push({ path: '/login' })
|
router.push({ path: '/login' })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import type { Router } from 'vue-router'
|
|||||||
import type { SessionIdRes } from '@/service/modules/login/types'
|
import type { SessionIdRes } from '@/service/modules/login/types'
|
||||||
import type { UserInfoRes } from '@/service/modules/users/types'
|
import type { UserInfoRes } from '@/service/modules/users/types'
|
||||||
import { useMenuStore } from '@/store/menu/menu'
|
import { useMenuStore } from '@/store/menu/menu'
|
||||||
|
import cookies from 'js-cookie'
|
||||||
|
|
||||||
export function useLogin(state: any) {
|
export function useLogin(state: any) {
|
||||||
const router: Router = useRouter()
|
const router: Router = useRouter()
|
||||||
@ -34,6 +35,7 @@ export function useLogin(state: any) {
|
|||||||
if (!valid) {
|
if (!valid) {
|
||||||
const loginRes: SessionIdRes = await login({ ...state.loginForm })
|
const loginRes: SessionIdRes = await login({ ...state.loginForm })
|
||||||
await userStore.setSessionId(loginRes.sessionId)
|
await userStore.setSessionId(loginRes.sessionId)
|
||||||
|
cookies.set('sessionId', loginRes.sessionId, { path: '/' })
|
||||||
|
|
||||||
const userInfoRes: UserInfoRes = await getUserInfo()
|
const userInfoRes: UserInfoRes = await getUserInfo()
|
||||||
await userStore.setUserInfo(userInfoRes)
|
await userStore.setUserInfo(userInfoRes)
|
||||||
|
Loading…
Reference in New Issue
Block a user