Copilot commented on code in PR #11703:
URL: https://github.com/apache/gravitino/pull/11703#discussion_r3425271438


##########
web-v2/web/src/lib/utils/axios/index.js:
##########
@@ -180,19 +181,25 @@ const transform = {
       return config
     }
 
-    // Use OAuth provider factory for proper token management
+    // Get authType from Redux store to determine which auth method to use
+    const authType = store.getState().auth.authType
+
     try {
-      const token = await oauthProviderFactory.getAccessToken()
-
-      if (token && config?.requestOptions?.withToken !== false) {
-        // ** jwt token
-        config.headers.Authorization = options.authenticationScheme ? 
`${options.authenticationScheme} ${token}` : token
-      } else if (window.sessionStorage.getItem('simpleAuthUser')) {
-        // Simple auth fallback
-        const simpleAuthToken = 
window.sessionStorage.getItem('simpleAuthToken')
+      if (authType === 'oauth') {

Review Comment:
   `authType` starts as `null` in the Redux slice and is only populated after 
`/configs` resolves. During that bootstrap window, this interceptor will skip 
adding an `Authorization` header entirely (even if an OAuth access token is 
already available), which can trigger spurious 401s/redirects on early API 
calls. Consider falling back to persisted auth artifacts (e.g., 
`localStorage.accessToken`) when `authType` is not yet known, while still 
avoiding the simple-auth fallback in OAuth mode.



##########
web-v2/web/src/lib/store/auth/index.js:
##########
@@ -150,11 +150,16 @@ export const logoutAction = createAsyncThunk(
 
       dispatch(clearIntervalId())
       dispatch(setAuthToken(''))
-      dispatch(setAuthUser(null))
     } else {
+      // Simple auth: clear simple auth user
       dispatch(setAuthUser(null))
     }

Review Comment:
   In the OAuth logout path, `authUser` in Redux is no longer cleared. This can 
leave stale user information in the UI after `router.push('/login')` (SPA 
navigation), even though the token is cleared. It also makes logout behavior 
inconsistent between auth types.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to