From: Lucas Di Pentima Date: Mon, 8 Mar 2021 17:04:45 +0000 (-0300) Subject: 16848: Resets extra cached token from the store when not valid anymore. X-Git-Tag: 2.1.2.1~10^2~5 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/eb633efdb3fa8ecb0c2c6a5e35916585282436ea?ds=sidebyside 16848: Resets extra cached token from the store when not valid anymore. This is to make the "Get API token" dialog default to the wb2's session token. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts index 27558618..4f576fe4 100644 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@ -23,6 +23,7 @@ export const authActions = unionize({ LOGOUT: ofType<{ deleteLinkData: boolean }>(), SET_CONFIG: ofType<{ config: Config }>(), SET_EXTRA_TOKEN: ofType<{ extraApiToken: string, extraApiTokenExpiration?: Date }>(), + RESET_EXTRA_TOKEN: {}, INIT_USER: ofType<{ user: User, token: string, tokenExpiration?: Date }>(), USER_DETAILS_REQUEST: {}, USER_DETAILS_SUCCESS: ofType(), @@ -112,7 +113,9 @@ export const getNewExtraToken = (reuseStored: boolean = false) => extraApiTokenExpiration: client.expiresAt ? new Date(client.expiresAt): undefined, })); return extraToken; - } catch (e) { } + } catch (e) { + dispatch(authActions.RESET_EXTRA_TOKEN()); + } } const user = getState().auth.user; const loginCluster = getState().auth.config.clusterConfig.Login.LoginCluster; diff --git a/src/store/auth/auth-reducer.ts b/src/store/auth/auth-reducer.ts index 7459b7ac..b29cf341 100644 --- a/src/store/auth/auth-reducer.ts +++ b/src/store/auth/auth-reducer.ts @@ -69,6 +69,8 @@ export const authReducer = (services: ServiceRepository) => (state = initialStat }), SET_EXTRA_TOKEN: ({ extraApiToken, extraApiTokenExpiration }) => ({ ...state, extraApiToken, extraApiTokenExpiration }), + RESET_EXTRA_TOKEN: () => + ({ ...state, extraApiToken: undefined, extraApiTokenExpiration: undefined }), INIT_USER: ({ user, token, tokenExpiration }) => ({ ...state, user,