dispatch(authActions.LOGIN());
};
-export const logout = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+export const logout = (deleteLinkData: boolean = false) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ if (deleteLinkData) {
+ services.linkAccountService.removeFromSession();
+ }
services.authService.removeApiToken();
services.authService.removeUser();
removeAuthorizationHeader(services.apiClient);
import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
import { LinkAccountType, AccountToLink } from "~/models/link-account";
-import { logout, saveApiToken, saveUser } from "~/store/auth/auth-action";
+import { saveApiToken, saveUser } from "~/store/auth/auth-action";
import { unionize, ofType, UnionOf } from '~/common/unionize';
import { UserResource } from "~/models/user";
import { GroupResource } from "~/models/group";
targetUser: UserResource | undefined,
userToLink: UserResource | undefined,
error: LinkAccountPanelError }>(),
+ HAS_SESSION_DATA: {}
});
export type LinkAccountPanelAction = UnionOf<typeof linkAccountPanelActions>;
export const loadLinkAccountPanel = () =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
dispatch(setBreadcrumbs([{ label: 'Link account'}]));
-
const curUser = getState().auth.user;
const curToken = getState().auth.apiToken;
if (curUser && curToken) {
// If there is link account session data, then the user has logged in a second time
if (linkAccountData) {
+
+ // If the window is refreshed after the second login, cancel the linking
+ if (window.performance) {
+ if (performance.navigation.type === PerformanceNavigation.TYPE_BACK_FORWARD ||
+ performance.navigation.type === PerformanceNavigation.TYPE_RELOAD) {
+ dispatch(cancelLinking());
+ return;
+ }
+ }
+
// Use the token of the user we are getting data for. This avoids any admin/non-admin permissions
// issues since a user will always be able to query the api server for their own user data.
dispatch(saveApiToken(linkAccountData.token));
(dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
const accountToLink = {type: t, userUuid: services.authService.getUuid(), token: services.authService.getApiToken()} as AccountToLink;
services.linkAccountService.saveToSession(accountToLink);
- dispatch(logout());
+ const auth = getState().auth;
+ services.authService.login(auth.localCluster, auth.remoteHosts[auth.homeCluster]);
};
export const getAccountLinkData = () =>
export enum LinkAccountPanelStatus {
INITIAL,
+ HAS_SESSION_DATA,
LINKING,
ERROR
}
}),
LINK_INVALID: ({originatingUser, targetUser, userToLink, error}) => ({
...state, originatingUser, targetUser, userToLink, error, status: LinkAccountPanelStatus.ERROR
+ }),
+ HAS_SESSION_DATA: () => ({
+ ...state, status: LinkAccountPanelStatus.HAS_SESSION_DATA
})
});
\ No newline at end of file
import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
import { loadSshKeysPanel } from '~/store/auth/auth-action-ssh';
import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions';
-import { loadLinkAccountPanel } from '~/store/link-account-panel/link-account-panel-actions';
+import { loadLinkAccountPanel, linkAccountPanelActions } from '~/store/link-account-panel/link-account-panel-actions';
import { loadSiteManagerPanel } from '~/store/auth/auth-action-session';
import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
import { DataTableFetchMode } from "~/components/data-table/data-table";
import { loadPublicFavoritePanel, publicFavoritePanelActions } from '~/store/public-favorites-panel/public-favorites-action';
import { publicFavoritePanelColumns } from '~/views/public-favorites-panel/public-favorites-panel';
+import { USER_LINK_ACCOUNT_KEY } from '~/services/link-account-service/link-account-service';
export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
dispatch(computeNodesActions.SET_COLUMNS({ columns: computeNodePanelColumns }));
dispatch(apiClientAuthorizationsActions.SET_COLUMNS({ columns: apiClientAuthorizationPanelColumns }));
+ if (sessionStorage.getItem(USER_LINK_ACCOUNT_KEY)) {
+ dispatch(linkAccountPanelActions.HAS_SESSION_DATA());
+ }
+
dispatch<any>(initSidePanelTree());
if (router.location) {
const match = matchRootRoute(router.location.pathname);
className={classes.link}>
Switch to Workbench v1</a></MenuItem>
<Divider />
- <MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
+ <MenuItem onClick={() => dispatch(logout(true))}>Logout</MenuItem>
</DropdownMenu>
: null));
import { InactivePanel } from '~/views/inactive-panel/inactive-panel';
import { WorkbenchLoadingScreen } from '~/views/workbench/workbench-loading-screen';
import { MainAppBar } from '~/views-components/main-app-bar/main-app-bar';
+import { LinkAccountPanel } from '~/views/link-account-panel/link-account-panel';
type CssRules = 'root';
loading: boolean;
buildInfo: string;
uuidPrefix: string;
+ isNotLinking: boolean;
}
type MainPanelRootProps = MainPanelRootDataProps & WithStyles<CssRules>;
export const MainPanelRoot = withStyles(styles)(
- ({ classes, loading, working, user, buildInfo, uuidPrefix }: MainPanelRootProps) =>
+ ({ classes, loading, working, user, buildInfo, uuidPrefix, isNotLinking }: MainPanelRootProps) =>
loading
? <WorkbenchLoadingScreen />
- : <>
- <MainAppBar
+ : <> { isNotLinking ? <>
+ <MainAppBar
user={user}
buildInfo={buildInfo}
uuidPrefix={uuidPrefix}>
{working ? <LinearProgress color="secondary" /> : null}
</MainAppBar>
<Grid container direction="column" className={classes.root}>
- {user ? (user.isActive ? <WorkbenchPanel /> : <InactivePanel />) : <LoginPanel />}
- </Grid>
- </>
+ { user ? (user.isActive ? <WorkbenchPanel /> : <InactivePanel />) : <LoginPanel />}
+ </Grid>
+ </> : user ? <LinkAccountPanel/> : <LoginPanel /> } </>
);
import { MainPanelRoot, MainPanelRootDataProps } from '~/views/main-panel/main-panel-root';
import { isSystemWorking } from '~/store/progress-indicator/progress-indicator-reducer';
import { isWorkbenchLoading } from '~/store/workbench/workbench-actions';
+import { LinkAccountPanelStatus } from '~/store/link-account-panel/link-account-panel-reducer';
const mapStateToProps = (state: RootState): MainPanelRootDataProps => {
return {
working: isSystemWorking(state.progressIndicator),
loading: isWorkbenchLoading(state),
buildInfo: state.appInfo.buildInfo,
- uuidPrefix: state.auth.localCluster
+ uuidPrefix: state.auth.localCluster,
+ isNotLinking: state.linkAccountPanel.status === LinkAccountPanelStatus.INITIAL
};
};