16848: Resets extra cached token from the store when not valid anymore.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 8 Mar 2021 17:04:45 +0000 (14:04 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 8 Mar 2021 17:04:45 +0000 (14:04 -0300)
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 <lucas@di-pentima.com.ar>

src/store/auth/auth-action.ts
src/store/auth/auth-reducer.ts

index 27558618d8017b17465e06ea388f03240a77b249..4f576fe4efcd83df36ef8641f330daddeeb9315e 100644 (file)
@@ -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 }>(),
     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<User>(),
     INIT_USER: ofType<{ user: User, token: string, tokenExpiration?: Date }>(),
     USER_DETAILS_REQUEST: {},
     USER_DETAILS_SUCCESS: ofType<User>(),
@@ -112,7 +113,9 @@ export const getNewExtraToken = (reuseStored: boolean = false) =>
                     extraApiTokenExpiration: client.expiresAt ? new Date(client.expiresAt): undefined,
                 }));
                 return extraToken;
                     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;
         }
         const user = getState().auth.user;
         const loginCluster = getState().auth.config.clusterConfig.Login.LoginCluster;
index 7459b7ac0c3a651e239a9b560baebd795d1884e0..b29cf3411a5650cc330ef0735a7fb768a95ade22 100644 (file)
@@ -69,6 +69,8 @@ export const authReducer = (services: ServiceRepository) => (state = initialStat
             }),
         SET_EXTRA_TOKEN: ({ extraApiToken, extraApiTokenExpiration }) =>
             ({ ...state, extraApiToken, extraApiTokenExpiration }),
             }),
         SET_EXTRA_TOKEN: ({ extraApiToken, extraApiTokenExpiration }) =>
             ({ ...state, extraApiToken, extraApiTokenExpiration }),
+        RESET_EXTRA_TOKEN: () =>
+            ({ ...state, extraApiToken: undefined, extraApiTokenExpiration: undefined }),
         INIT_USER: ({ user, token, tokenExpiration }) =>
             ({ ...state,
                 user,
         INIT_USER: ({ user, token, tokenExpiration }) =>
             ({ ...state,
                 user,