File tree Expand file tree Collapse file tree
openmetadata-ui/src/main/resources/ui/src
components/Auth/AuthProviders Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ import {
8181import { getPathNameFromWindowLocation } from '../../../utils/RouterUtils' ;
8282import { escapeESReservedCharacters } from '../../../utils/StringsUtils' ;
8383import {
84+ clearOidcToken ,
8485 getOidcToken ,
8586 getRefreshToken ,
8687 setOidcToken ,
@@ -264,7 +265,7 @@ export const AuthProvider = ({
264265
265266 const resetUserDetails = ( forceLogout = false ) => {
266267 setCurrentUser ( { } as User ) ;
267- setOidcToken ( '' ) ;
268+ clearOidcToken ( ) ;
268269 setRefreshToken ( '' ) ;
269270 setIsAuthenticated ( false ) ;
270271 setApplicationLoading ( false ) ;
Original file line number Diff line number Diff line change @@ -67,6 +67,21 @@ const setAppState = async (state: AppState): Promise<void> => {
6767 }
6868} ;
6969
70+ const clearAppState = async ( ) : Promise < void > => {
71+ try {
72+ if ( isServiceWorkerAvailable ( ) ) {
73+ await swTokenStorage . removeItem ( APP_STATE_KEY ) ;
74+ } else {
75+ // Fallback for browsers that don't support SW/IndexedDB
76+ localStorage . removeItem ( APP_STATE_KEY ) ;
77+ }
78+ } catch {
79+ // Storage failures are intentionally ignored to prevent auth flows from breaking.
80+ // Token persistence is treated as "best effort" - if storage fails, the user
81+ // may need to re-authenticate, but core functionality continues working.
82+ }
83+ } ;
84+
7085export const getOidcToken = async ( ) : Promise < string > => {
7186 try {
7287 const state = await getAppState ( ) ;
@@ -110,3 +125,13 @@ export const setRefreshToken = async (token: string): Promise<void> => {
110125 // may need to re-authenticate, but core functionality continues working.
111126 }
112127} ;
128+
129+ export const clearOidcToken = async ( ) : Promise < void > => {
130+ try {
131+ await clearAppState ( ) ;
132+ } catch {
133+ // Storage failures are intentionally ignored to prevent auth flows from breaking.
134+ // Token persistence is treated as "best effort" - if storage fails, the user
135+ // may need to re-authenticate, but core functionality continues working.
136+ }
137+ } ;
You can’t perform that action at this time.
0 commit comments