From 6d56193307e3c9f5949ab9e1cd5d2e1dc96c2448 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 15 Nov 2024 22:36:11 +0530 Subject: [PATCH] fix: token refresh failed handle it Signed-off-by: Pranav C --- packages/nc-gui/composables/useApi/interceptors.ts | 8 ++++++++ packages/nc-gui/composables/useGlobal/types.ts | 6 +++++- packages/nocodb-sdk/src/lib/Api.ts | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/composables/useApi/interceptors.ts b/packages/nc-gui/composables/useApi/interceptors.ts index b4e9914a52..0fde440f8a 100644 --- a/packages/nc-gui/composables/useApi/interceptors.ts +++ b/packages/nc-gui/composables/useApi/interceptors.ts @@ -67,6 +67,14 @@ export function addAxiosInterceptors(api: Api) { skipLogout: true, }) + if (!token) { + await state.signOut({ + redirectToSignin: !isSharedPage, + skipApiCall: true, + }) + return Promise.reject(error) + } + const config = error.config config.headers['xc-auth'] = token diff --git a/packages/nc-gui/composables/useGlobal/types.ts b/packages/nc-gui/composables/useGlobal/types.ts index 1ad3975705..8696bd0475 100644 --- a/packages/nc-gui/composables/useGlobal/types.ts +++ b/packages/nc-gui/composables/useGlobal/types.ts @@ -92,7 +92,11 @@ export interface SignOutParams { export interface Actions { signOut: (signOutParams?: SignOutParams) => Promise signIn: (token: string, keepProps?: boolean) => void - refreshToken: (params: { axiosInstance?: AxiosInstance; skipLogout?: boolean; cognitoOnly?: boolean }) => Promise + refreshToken: (params: { + axiosInstance?: AxiosInstance + skipLogout?: boolean + cognitoOnly?: boolean + }) => Promise loadAppInfo: () => void setIsMobileMode: (isMobileMode: boolean) => void navigateToProject: (params: { workspaceId?: string; baseId?: string; type?: NcProjectType; query?: any }) => void diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 53368059b2..f77572d6d5 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2846,6 +2846,8 @@ export interface ViewType { | MapType | CalendarType | (FormType & GalleryType & GridType & KanbanType & MapType & CalendarType); + /** ID of view owner user */ + owned_by?: IdType; } /** @@ -2918,6 +2920,8 @@ export interface ViewUpdateReqType { order?: number; /** Should this view show system fields? */ show_system_fields?: BoolType; + /** ID of view owner user */ + owned_by?: IdType; } /**