1+ import { useQueryClient } from '@tanstack/react-query' ;
12import {
23 checkErrors ,
34 clearAuth ,
@@ -8,10 +9,17 @@ import {
89 saveAuthKey ,
910} from 'app/util/auth' ;
1011import { createRequestInit } from 'app/util/queries' ;
11- import { createContext , type ReactNode , useCallback , useContext , useMemo , useState } from 'react' ;
12- import { useSerilogUiProps } from './useSerilogUiProps' ;
12+ import {
13+ createContext ,
14+ type ReactNode ,
15+ useCallback ,
16+ useContext ,
17+ useMemo ,
18+ useState ,
19+ } from 'react' ;
20+ import { AuthType , DispatchedCustomEvents } from '../../types/types.ts' ;
1321import { isStringGuard } from '../util/guards.ts' ;
14- import { AuthType } from '../../types/types.ts ' ;
22+ import { useSerilogUiProps } from './useSerilogUiProps ' ;
1523
1624interface AuthProps {
1725 authProps : IAuthPropertiesData ;
@@ -46,6 +54,7 @@ export const AuthPropertiesProvider = ({
4654} : {
4755 children : ReactNode | undefined ;
4856} ) => {
57+ const queryClient = useQueryClient ( ) ;
4958 const { authType, routePrefix } = useSerilogUiProps ( ) ;
5059
5160 const [ authInfo , setAuthInfo ] = useState < IAuthPropertiesData > ( {
@@ -57,7 +66,7 @@ export const AuthPropertiesProvider = ({
5766 [ authInfo , authType ] ,
5867 ) ;
5968 const isHeaderReady = authType === AuthType . Custom || isStringGuard ( authHeader ) ;
60-
69+
6170 const fetchInfo = useMemo (
6271 ( ) => ( {
6372 headers : createRequestInit ( authType , authHeader ) ,
@@ -68,8 +77,12 @@ export const AuthPropertiesProvider = ({
6877
6978 const clearAuthState = useCallback ( ( ) => {
7079 const cleanState = clearAuth ( ) ;
80+
81+ queryClient . removeQueries ( { queryKey : [ 'get-keys' ] , exact : false } ) ;
82+ document . dispatchEvent ( new CustomEvent ( DispatchedCustomEvents . RemoveTableKey ) ) ;
83+
7184 setAuthInfo ( cleanState ) ;
72- } , [ ] ) ;
85+ } , [ queryClient ] ) ;
7386
7487 const saveAuthState = useCallback ( ( input : { [ key : string ] : string } ) => {
7588 const validationInfo : string [ ] = [ ] ;
@@ -114,8 +127,14 @@ export const AuthPropertiesProvider = ({
114127} ;
115128
116129export const useAuthProperties = ( ) => {
117- const { authProps, authHeader, fetchInfo, isHeaderReady, clearAuthState, saveAuthState } =
118- useContext ( AuthPropertiesContext ) ;
130+ const {
131+ authProps,
132+ authHeader,
133+ fetchInfo,
134+ isHeaderReady,
135+ clearAuthState,
136+ saveAuthState,
137+ } = useContext ( AuthPropertiesContext ) ;
119138
120139 return {
121140 ...authProps ,
0 commit comments