- const user = services.authService.getUser();
- const token = services.authService.getApiToken();
- const homeCluster = services.authService.getHomeCluster();
- if (token) {
- setAuthorizationHeader(services, token);
- }
- dispatch(authActions.CONFIG({ config }));
- dispatch(authActions.SET_HOME_CLUSTER(homeCluster || config.uuidPrefix));
- if (token && user) {
- dispatch(authActions.INIT({ user, token }));
- dispatch<any>(initSessions(services.authService, config, user));
- dispatch<any>(getUserDetails()).then((user: User) => {
- dispatch(authActions.INIT({ user, token }));
- }).catch((err: AxiosError) => {
- if (err.response) {
- // Bad token
- if (err.response.status === 401) {
- logout()(dispatch, getState, services);
- }
- }
+ // Cancel any link account ops in progress unless the user has
+ // just logged in or there has been a successful link operation
+ const data = services.linkAccountService.getLinkOpStatus();
+ if (!matchTokenRoute(location.pathname) &&
+ (!matchFedTokenRoute(location.pathname)) && data === undefined) {
+ dispatch<any>(cancelLinking()).then(() => {
+ dispatch<any>(init(config));