From: Eric Biagiotti Date: Tue, 14 May 2019 21:32:04 +0000 (-0400) Subject: 15088: Moves link account operation check to initAuth X-Git-Tag: 1.4.0~1^2~14 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/967f2bb4cc911c0f3dae6246ac81e19c177751ba 15088: Moves link account operation check to initAuth Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti --- diff --git a/src/index.tsx b/src/index.tsx index 014627a9..9f9b27ca 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -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(cancelLinking()); - } - store.subscribe(initListener(history, store, services, config)); store.dispatch(initAuth(config)); store.dispatch(setBuildInfo()); diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts index 8be02ed0..7ee83992 100644 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@ -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(), @@ -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(cancelLinking()); + } + const user = services.authService.getUser(); const token = services.authService.getApiToken(); if (token) {