Browse Source

[BUG-12306][UI]Fix the password item always is disabled (#12437)

* Fix the password item always is disabled
3.2.0-release
Kerwin 2 years ago committed by GitHub
parent
commit
651588c98d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts
  2. 4
      dolphinscheduler-ui/src/layouts/content/use-dataList.ts
  3. 5
      dolphinscheduler-ui/src/service/modules/login/types.ts
  4. 1
      dolphinscheduler-ui/src/service/modules/users/types.ts
  5. 1
      dolphinscheduler-ui/src/service/service.ts
  6. 1
      dolphinscheduler-ui/src/store/user/types.ts
  7. 7
      dolphinscheduler-ui/src/store/user/user.ts
  8. 5
      dolphinscheduler-ui/src/views/login/use-login.ts
  9. 1
      dolphinscheduler-ui/src/views/password/use-update.ts

1
dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts

@ -39,6 +39,7 @@ export function useDropDown() {
const useLogout = () => { const useLogout = () => {
logout().then(() => { logout().then(() => {
userStore.setSessionId('') userStore.setSessionId('')
userStore.setSecurityConfigType('')
userStore.setUserInfo({}) userStore.setUserInfo({})
cookies.remove('sessionId') cookies.remove('sessionId')

4
dolphinscheduler-ui/src/layouts/content/use-dataList.ts

@ -349,9 +349,7 @@ export function useDataList() {
label: t('user_dropdown.password'), label: t('user_dropdown.password'),
key: 'password', key: 'password',
icon: renderIcon(KeyOutlined), icon: renderIcon(KeyOutlined),
disabled: disabled: userStore.getSecurityConfigType !== 'PASSWORD'
(userStore.getUserInfo as UserInfoRes).securityConfigType !==
'PASSWORD'
}, },
{ {
label: t('user_dropdown.logout'), label: t('user_dropdown.logout'),

5
dolphinscheduler-ui/src/service/modules/login/types.ts

@ -20,8 +20,9 @@ interface LoginReq {
userPassword: string userPassword: string
} }
interface SessionIdRes { interface LoginRes {
securityConfigType: string
sessionId: string sessionId: string
} }
export { LoginReq, SessionIdRes } export { LoginReq, LoginRes }

1
dolphinscheduler-ui/src/service/modules/users/types.ts

@ -100,7 +100,6 @@ interface UserInfoRes extends UserReq, IdReq {
alertGroup?: any alertGroup?: any
createTime: string createTime: string
updateTime: string updateTime: string
securityConfigType: 'PASSWORD' | 'LDAP'
} }
interface UserListRes { interface UserListRes {

1
dolphinscheduler-ui/src/service/service.ts

@ -61,6 +61,7 @@ const service = axios.create(baseRequestConfig)
const err = (err: AxiosError): Promise<AxiosError> => { const err = (err: AxiosError): Promise<AxiosError> => {
if (err.response?.status === 401 || err.response?.status === 504) { if (err.response?.status === 401 || err.response?.status === 504) {
userStore.setSessionId('') userStore.setSessionId('')
userStore.setSecurityConfigType('')
userStore.setUserInfo({}) userStore.setUserInfo({})
router.push({ path: '/login' }) router.push({ path: '/login' })
} }

1
dolphinscheduler-ui/src/store/user/types.ts

@ -19,6 +19,7 @@ import type { UserInfoRes } from '@/service/modules/users/types'
interface UserState { interface UserState {
sessionId: string sessionId: string
securityConfigType: string
userInfo: UserInfoRes | {} userInfo: UserInfoRes | {}
} }

7
dolphinscheduler-ui/src/store/user/user.ts

@ -23,6 +23,7 @@ export const useUserStore = defineStore({
id: 'user', id: 'user',
state: (): UserState => ({ state: (): UserState => ({
sessionId: '', sessionId: '',
securityConfigType: '',
userInfo: {} userInfo: {}
}), }),
persist: true, persist: true,
@ -30,6 +31,9 @@ export const useUserStore = defineStore({
getSessionId(): string { getSessionId(): string {
return this.sessionId return this.sessionId
}, },
getSecurityConfigType(): string {
return this.securityConfigType
},
getUserInfo(): UserInfoRes | {} { getUserInfo(): UserInfoRes | {} {
return this.userInfo return this.userInfo
} }
@ -38,6 +42,9 @@ export const useUserStore = defineStore({
setSessionId(sessionId: string): void { setSessionId(sessionId: string): void {
this.sessionId = sessionId this.sessionId = sessionId
}, },
setSecurityConfigType(securityConfigType: string): void {
this.securityConfigType = securityConfigType
},
setUserInfo(userInfo: UserInfoRes | {}): void { setUserInfo(userInfo: UserInfoRes | {}): void {
this.userInfo = userInfo this.userInfo = userInfo
} }

5
dolphinscheduler-ui/src/views/login/use-login.ts

@ -20,7 +20,7 @@ import { login } from '@/service/modules/login'
import { getUserInfo } from '@/service/modules/users' import { getUserInfo } from '@/service/modules/users'
import { useUserStore } from '@/store/user/user' import { useUserStore } from '@/store/user/user'
import type { Router } from 'vue-router' import type { Router } from 'vue-router'
import type { SessionIdRes } from '@/service/modules/login/types' import type { LoginRes } from '@/service/modules/login/types'
import type { UserInfoRes } from '@/service/modules/users/types' import type { UserInfoRes } from '@/service/modules/users/types'
import { useRouteStore } from '@/store/route/route' import { useRouteStore } from '@/store/route/route'
import { useTimezoneStore } from '@/store/timezone/timezone' import { useTimezoneStore } from '@/store/timezone/timezone'
@ -34,8 +34,9 @@ export function useLogin(state: any) {
const handleLogin = () => { const handleLogin = () => {
state.loginFormRef.validate(async (valid: any) => { state.loginFormRef.validate(async (valid: any) => {
if (!valid) { if (!valid) {
const loginRes: SessionIdRes = await login({ ...state.loginForm }) const loginRes: LoginRes = await login({ ...state.loginForm })
await userStore.setSessionId(loginRes.sessionId) await userStore.setSessionId(loginRes.sessionId)
await userStore.setSecurityConfigType(loginRes.securityConfigType)
const userInfoRes: UserInfoRes = await getUserInfo() const userInfoRes: UserInfoRes = await getUserInfo()
await userStore.setUserInfo(userInfoRes) await userStore.setUserInfo(userInfoRes)

1
dolphinscheduler-ui/src/views/password/use-update.ts

@ -40,6 +40,7 @@ export function useUpdate(state: any) {
}) })
await userStore.setSessionId('') await userStore.setSessionId('')
await userStore.setSecurityConfigType('')
await userStore.setUserInfo({}) await userStore.setUserInfo({})
await router.push({ path: 'login' }) await router.push({ path: 'login' })
} }

Loading…
Cancel
Save