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

kirs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new c683bd6ec [Feat][UI] Update login function in the project. (#2773)
c683bd6ec is described below

commit c683bd6ec7708a77c5ace1627789932fdb19d3af
Author: songjianet <[email protected]>
AuthorDate: Sun Sep 18 17:02:36 2022 +0800

    [Feat][UI] Update login function in the project. (#2773)
---
 seatunnel-ui/src/service/service.ts    | 8 ++++++++
 seatunnel-ui/src/service/user/types.ts | 1 +
 2 files changed, 9 insertions(+)

diff --git a/seatunnel-ui/src/service/service.ts 
b/seatunnel-ui/src/service/service.ts
index 305318112..af88099b6 100644
--- a/seatunnel-ui/src/service/service.ts
+++ b/seatunnel-ui/src/service/service.ts
@@ -17,6 +17,10 @@
 
 import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'
 import utils from '@/utils'
+import { useUserStore } from '@/store/user'
+import type { UserDetail } from '@/service/user/types'
+
+const userStore = useUserStore()
 
 const handleError = (res: AxiosResponse<any, any>) => {
   if (import.meta.env.MODE === 'development') {
@@ -39,6 +43,10 @@ const err = (err: AxiosError): Promise<AxiosError> => {
 }
 
 service.interceptors.request.use((config: AxiosRequestConfig<any>) => {
+  if (Object.keys(userStore.getUserInfo).length > 0) {
+    config.headers && (config.headers.token = (userStore.getUserInfo as 
UserDetail).token as string)
+  }
+
   return config
 }, err)
 
diff --git a/seatunnel-ui/src/service/user/types.ts 
b/seatunnel-ui/src/service/user/types.ts
index 392765131..1df16fa37 100644
--- a/seatunnel-ui/src/service/user/types.ts
+++ b/seatunnel-ui/src/service/user/types.ts
@@ -29,6 +29,7 @@ interface UserLogin {
 interface UserDetail extends UserLogin {
   status: string
   type: string
+  token?: string
   id?: number
   name?: string
   createTime?: any | null

Reply via email to