From 2d1672726efec347d0d90e4ca9273675d9a0209c Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:40:46 -0700 Subject: [PATCH] Update intercept to check logout request (#1650) (#1657) * update intercept to check logout request * change controller to unused variable --------- (cherry picked from commit 606bc71a5328a99f060d2d766cb849b2cbf8d034) Signed-off-by: Shenoy Pratik Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- public/framework/catalog_cache/cache_intercept.ts | 14 +++++++------- public/plugin.tsx | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/public/framework/catalog_cache/cache_intercept.ts b/public/framework/catalog_cache/cache_intercept.ts index 3f50bf00b..f3ed0ca34 100644 --- a/public/framework/catalog_cache/cache_intercept.ts +++ b/public/framework/catalog_cache/cache_intercept.ts @@ -3,15 +3,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { - HttpInterceptorResponseError, - IHttpInterceptController, -} from '../../../../../src/core/public'; +import { HttpFetchOptionsWithPath, IHttpInterceptController } from '../../../../../src/core/public'; import { CatalogCacheManager } from './cache_manager'; -export function catalogCacheInterceptError(): any { - return (httpErrorResponse: HttpInterceptorResponseError, _: IHttpInterceptController) => { - if (httpErrorResponse.response?.status === 401) { +export function catalogRequestIntercept(): any { + return ( + fetchOptions: Readonly, + _controller: IHttpInterceptController + ) => { + if (fetchOptions.path.includes('/logout')) { // Clears all user catalog cache details CatalogCacheManager.clearDataSourceCache(); CatalogCacheManager.clearAccelerationsCache(); diff --git a/public/plugin.tsx b/public/plugin.tsx index c3416c759..cbcc35c73 100644 --- a/public/plugin.tsx +++ b/public/plugin.tsx @@ -20,7 +20,6 @@ import { createGetterSetter } from '../../../src/plugins/opensearch_dashboards_u import { CREATE_TAB_PARAM, CREATE_TAB_PARAM_KEY, TAB_CHART_ID } from '../common/constants/explorer'; import { DATACONNECTIONS_BASE, - S3_DATASOURCE_TYPE, observabilityApplicationsID, observabilityApplicationsPluginOrder, observabilityApplicationsTitle, @@ -46,6 +45,7 @@ import { observabilityTracesID, observabilityTracesPluginOrder, observabilityTracesTitle, + S3_DATASOURCE_TYPE, } from '../common/constants/shared'; import { QueryManager } from '../common/query_manager'; import { AssociatedObject, CachedAcceleration } from '../common/types/data_connections'; @@ -72,7 +72,7 @@ import { OBSERVABILITY_EMBEDDABLE_ID, } from './embeddable/observability_embeddable'; import { ObservabilityEmbeddableFactoryDefinition } from './embeddable/observability_embeddable_factory'; -import { catalogCacheInterceptError } from './framework/catalog_cache/cache_intercept'; +import { catalogRequestIntercept } from './framework/catalog_cache/cache_intercept'; import { useLoadAccelerationsToCache, useLoadDatabasesToCache, @@ -402,7 +402,7 @@ export class ObservabilityPlugin }); core.http.intercept({ - responseError: catalogCacheInterceptError(), + request: catalogRequestIntercept(), }); // Use overlay service to render flyouts