15088: Moves link account operation check to initAuth
authorEric Biagiotti <ebiagiotti@veritasgenetics.com>
Tue, 14 May 2019 21:32:04 +0000 (17:32 -0400)
committerEric Biagiotti <ebiagiotti@veritasgenetics.com>
Tue, 14 May 2019 21:32:04 +0000 (17:32 -0400)
Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti@veritasgenetics.com>

src/index.tsx
src/store/auth/auth-action.ts

index 014627a9b2ea06e089e2e0bf7e902b51e29ce4f0..9f9b27ca912809f4730435382214a8d5ced02eeb 100644 (file)
@@ -64,9 +64,6 @@ import { loadFileViewersConfig } from '~/store/file-viewers/file-viewers-actions
 import { collectionAdminActionSet } from '~/views-components/context-menu/action-sets/collection-admin-action-set';
 import { processResourceAdminActionSet } from '~/views-components/context-menu/action-sets/process-resource-admin-action-set';
 import { projectAdminActionSet } from '~/views-components/context-menu/action-sets/project-admin-action-set';
-import { ACCOUNT_LINK_STATUS_KEY } from '~/services/link-account-service/link-account-service';
-import { cancelLinking } from '~/store/link-account-panel/link-account-panel-actions';
-import { matchTokenRoute } from '~/routes/routes';
 
 console.log(`Starting arvados [${getBuildInfo()}]`);
 
@@ -111,13 +108,6 @@ fetchConfig()
         });
         const store = configureStore(history, services);
 
-        // Cancel any link account ops in progess unless the user has
-        // just logged in or there has been a successful link operation
-        const data = sessionStorage.getItem(ACCOUNT_LINK_STATUS_KEY);
-        if (!matchTokenRoute(history.location.pathname) && data === null) {
-            store.dispatch<any>(cancelLinking());
-        }
-
         store.subscribe(initListener(history, store, services, config));
         store.dispatch(initAuth(config));
         store.dispatch(setBuildInfo());
index 8be02ed02ab426dae71000ee1aca3295510f15e4..7ee8399286c381287fb60b236f15ed87ea0df90b 100644 (file)
@@ -12,7 +12,8 @@ import { User, UserResource } from "~/models/user";
 import { Session } from "~/models/session";
 import { Config } from '~/common/config';
 import { initSessions } from "~/store/auth/auth-action-session";
-import { UserRepositoryCreate } from '~/views-components/dialog-create/dialog-user-create';
+import { cancelLinking } from '~/store/link-account-panel/link-account-panel-actions';
+import { matchTokenRoute } from '~/routes/routes';
 
 export const authActions = unionize({
     SAVE_API_TOKEN: ofType<string>(),
@@ -47,6 +48,13 @@ function removeAuthorizationHeader(client: AxiosInstance) {
 }
 
 export const initAuth = (config: Config) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+    // Cancel any link account ops in progess unless the user has
+    // just logged in or there has been a successful link operation
+    const data = services.linkAccountService.getLinkOpStatus();
+    if (!matchTokenRoute(location.pathname) && data === undefined) {
+        dispatch<any>(cancelLinking());
+    }
+
     const user = services.authService.getUser();
     const token = services.authService.getApiToken();
     if (token) {