You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ke...@apache.org on 2022/10/21 01:33:23 UTC

[dolphinscheduler] branch 3.1.1-prepare updated: [BUG-12306][UI]Fix the password item always is disabled (#12437)

This is an automated email from the ASF dual-hosted git repository.

kerwin pushed a commit to branch 3.1.1-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/3.1.1-prepare by this push:
     new a92f766843 [BUG-12306][UI]Fix the password item always is disabled (#12437)
a92f766843 is described below

commit a92f76684339bebbb3eb45c739f4d90edbf1167a
Author: Kerwin <37...@users.noreply.github.com>
AuthorDate: Fri Oct 21 09:27:50 2022 +0800

    [BUG-12306][UI]Fix the password item always is disabled (#12437)
    
    * Fix the password item always is disabled
---
 .../src/layouts/content/components/user/use-dropdown.ts            | 1 +
 dolphinscheduler-ui/src/layouts/content/use-dataList.ts            | 4 +---
 dolphinscheduler-ui/src/service/modules/login/types.ts             | 5 +++--
 dolphinscheduler-ui/src/service/modules/users/types.ts             | 1 -
 dolphinscheduler-ui/src/service/service.ts                         | 1 +
 dolphinscheduler-ui/src/store/user/types.ts                        | 1 +
 dolphinscheduler-ui/src/store/user/user.ts                         | 7 +++++++
 dolphinscheduler-ui/src/views/login/use-login.ts                   | 5 +++--
 dolphinscheduler-ui/src/views/password/use-update.ts               | 1 +
 9 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts b/dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts
index 3a086ad817..6ad6ea0517 100644
--- a/dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts
+++ b/dolphinscheduler-ui/src/layouts/content/components/user/use-dropdown.ts
@@ -39,6 +39,7 @@ export function useDropDown() {
   const useLogout = () => {
     logout().then(() => {
       userStore.setSessionId('')
+      userStore.setSecurityConfigType('')
       userStore.setUserInfo({})
       cookies.remove('sessionId')
 
diff --git a/dolphinscheduler-ui/src/layouts/content/use-dataList.ts b/dolphinscheduler-ui/src/layouts/content/use-dataList.ts
index 0d8fb17731..242859e33d 100644
--- a/dolphinscheduler-ui/src/layouts/content/use-dataList.ts
+++ b/dolphinscheduler-ui/src/layouts/content/use-dataList.ts
@@ -341,9 +341,7 @@ export function useDataList() {
         label: t('user_dropdown.password'),
         key: 'password',
         icon: renderIcon(KeyOutlined),
-        disabled:
-          (userStore.getUserInfo as UserInfoRes).securityConfigType !==
-          'PASSWORD'
+        disabled: userStore.getSecurityConfigType !== 'PASSWORD'
       },
       {
         label: t('user_dropdown.logout'),
diff --git a/dolphinscheduler-ui/src/service/modules/login/types.ts b/dolphinscheduler-ui/src/service/modules/login/types.ts
index 05ce943f1f..d0471de8da 100644
--- a/dolphinscheduler-ui/src/service/modules/login/types.ts
+++ b/dolphinscheduler-ui/src/service/modules/login/types.ts
@@ -20,8 +20,9 @@ interface LoginReq {
   userPassword: string
 }
 
-interface SessionIdRes {
+interface LoginRes {
+  securityConfigType: string
   sessionId: string
 }
 
-export { LoginReq, SessionIdRes }
+export { LoginReq, LoginRes }
diff --git a/dolphinscheduler-ui/src/service/modules/users/types.ts b/dolphinscheduler-ui/src/service/modules/users/types.ts
index fe06d8be0f..33de77e215 100644
--- a/dolphinscheduler-ui/src/service/modules/users/types.ts
+++ b/dolphinscheduler-ui/src/service/modules/users/types.ts
@@ -100,7 +100,6 @@ interface UserInfoRes extends UserReq, IdReq {
   alertGroup?: any
   createTime: string
   updateTime: string
-  securityConfigType: 'PASSWORD' | 'LDAP'
 }
 
 interface UserListRes {
diff --git a/dolphinscheduler-ui/src/service/service.ts b/dolphinscheduler-ui/src/service/service.ts
index 8d33534788..95b0a35fd9 100644
--- a/dolphinscheduler-ui/src/service/service.ts
+++ b/dolphinscheduler-ui/src/service/service.ts
@@ -61,6 +61,7 @@ const service = axios.create(baseRequestConfig)
 const err = (err: AxiosError): Promise<AxiosError> => {
   if (err.response?.status === 401 || err.response?.status === 504) {
     userStore.setSessionId('')
+    userStore.setSecurityConfigType('')
     userStore.setUserInfo({})
     router.push({ path: '/login' })
   }
diff --git a/dolphinscheduler-ui/src/store/user/types.ts b/dolphinscheduler-ui/src/store/user/types.ts
index 58657ea928..208d500f82 100644
--- a/dolphinscheduler-ui/src/store/user/types.ts
+++ b/dolphinscheduler-ui/src/store/user/types.ts
@@ -19,6 +19,7 @@ import type { UserInfoRes } from '@/service/modules/users/types'
 
 interface UserState {
   sessionId: string
+  securityConfigType: string
   userInfo: UserInfoRes | {}
 }
 
diff --git a/dolphinscheduler-ui/src/store/user/user.ts b/dolphinscheduler-ui/src/store/user/user.ts
index 92feec46f1..3f7e76644b 100644
--- a/dolphinscheduler-ui/src/store/user/user.ts
+++ b/dolphinscheduler-ui/src/store/user/user.ts
@@ -23,6 +23,7 @@ export const useUserStore = defineStore({
   id: 'user',
   state: (): UserState => ({
     sessionId: '',
+    securityConfigType: '',
     userInfo: {}
   }),
   persist: true,
@@ -30,6 +31,9 @@ export const useUserStore = defineStore({
     getSessionId(): string {
       return this.sessionId
     },
+    getSecurityConfigType(): string {
+      return this.securityConfigType
+    },
     getUserInfo(): UserInfoRes | {} {
       return this.userInfo
     }
@@ -38,6 +42,9 @@ export const useUserStore = defineStore({
     setSessionId(sessionId: string): void {
       this.sessionId = sessionId
     },
+    setSecurityConfigType(securityConfigType: string): void {
+      this.securityConfigType = securityConfigType
+    },
     setUserInfo(userInfo: UserInfoRes | {}): void {
       this.userInfo = userInfo
     }
diff --git a/dolphinscheduler-ui/src/views/login/use-login.ts b/dolphinscheduler-ui/src/views/login/use-login.ts
index 6fd2080e55..51f387e691 100644
--- a/dolphinscheduler-ui/src/views/login/use-login.ts
+++ b/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 { useUserStore } from '@/store/user/user'
 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 { useRouteStore } from '@/store/route/route'
 import { useTimezoneStore } from '@/store/timezone/timezone'
@@ -34,8 +34,9 @@ export function useLogin(state: any) {
   const handleLogin = () => {
     state.loginFormRef.validate(async (valid: any) => {
       if (!valid) {
-        const loginRes: SessionIdRes = await login({ ...state.loginForm })
+        const loginRes: LoginRes = await login({ ...state.loginForm })
         await userStore.setSessionId(loginRes.sessionId)
+        await userStore.setSecurityConfigType(loginRes.securityConfigType)
 
         const userInfoRes: UserInfoRes = await getUserInfo()
         await userStore.setUserInfo(userInfoRes)
diff --git a/dolphinscheduler-ui/src/views/password/use-update.ts b/dolphinscheduler-ui/src/views/password/use-update.ts
index 3d70b2c9fa..b8987298c9 100644
--- a/dolphinscheduler-ui/src/views/password/use-update.ts
+++ b/dolphinscheduler-ui/src/views/password/use-update.ts
@@ -40,6 +40,7 @@ export function useUpdate(state: any) {
         })
 
         await userStore.setSessionId('')
+        await userStore.setSecurityConfigType('')
         await userStore.setUserInfo({})
         await router.push({ path: 'login' })
       }