|
|
@ -1,6 +1,8 @@ |
|
|
|
import type { Api } from 'nocodb-sdk' |
|
|
|
import type { Api } from 'nocodb-sdk' |
|
|
|
const DbNotFoundMsg = 'Database config not found' |
|
|
|
const DbNotFoundMsg = 'Database config not found' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const TIMEOUT_RETRY_COUNT = 1 |
|
|
|
|
|
|
|
|
|
|
|
export function addAxiosInterceptors(api: Api<any>) { |
|
|
|
export function addAxiosInterceptors(api: Api<any>) { |
|
|
|
const state = useGlobal() |
|
|
|
const state = useGlobal() |
|
|
|
const router = useRouter() |
|
|
|
const router = useRouter() |
|
|
@ -61,6 +63,8 @@ export function addAxiosInterceptors(api: Api<any>) { |
|
|
|
return Promise.reject(error) |
|
|
|
return Promise.reject(error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let retry = 0 |
|
|
|
|
|
|
|
do { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const token = await state.refreshToken({ |
|
|
|
const token = await state.refreshToken({ |
|
|
|
axiosInstance, |
|
|
|
axiosInstance, |
|
|
@ -85,13 +89,18 @@ export function addAxiosInterceptors(api: Api<any>) { |
|
|
|
return Promise.reject(refreshTokenError) |
|
|
|
return Promise.reject(refreshTokenError) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if shared execution error, don't sign out
|
|
|
|
|
|
|
|
if (!(refreshTokenError instanceof SharedExecutionError)) { |
|
|
|
await state.signOut({ |
|
|
|
await state.signOut({ |
|
|
|
redirectToSignin: !isSharedPage, |
|
|
|
redirectToSignin: !isSharedPage, |
|
|
|
skipApiCall: true, |
|
|
|
skipApiCall: true, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return Promise.reject(error) |
|
|
|
return Promise.reject(error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (retry >= TIMEOUT_RETRY_COUNT) return Promise.reject(error) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} while (retry++ < TIMEOUT_RETRY_COUNT) |
|
|
|
}, |
|
|
|
}, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|