localStorage.removeItem(USER_PREFS);
}
- public login(uuidPrefix: string, homeCluster: string) {
+ public login(uuidPrefix: string, homeCluster: string, remoteHosts: { [key: string]: string }) {
const currentUrl = `${window.location.protocol}//${window.location.host}/token`;
- window.location.assign(`https://${homeCluster}/login?remote=${uuidPrefix}&return_to=${currentUrl}`);
+ const homeClusterHost = remoteHosts[homeCluster];
+ window.location.assign(`https://${homeClusterHost}/login?${uuidPrefix !== homeCluster ? "remote=" + uuidPrefix + "&" : ""}return_to=${currentUrl}`);
}
public logout() {
dispatch<any>(getUserDetails()).then((user: User) => {
dispatch(authActions.INIT({ user, token }));
});
- Object.keys(config.remoteHosts).map((k) => {
- Axios.get<Config>(getDiscoveryURL(config.remoteHosts[k]))
- .then(response => dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config: response.data })));
- });
}
+ Object.keys(config.remoteHosts).map((k) => {
+ Axios.get<Config>(getDiscoveryURL(config.remoteHosts[k]))
+ .then(response => dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config: response.data })));
+ });
};
export const saveApiToken = (token: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch(authActions.SAVE_API_TOKEN(token));
};
-export const login = (uuidPrefix: string, homeCluster: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- services.authService.login(uuidPrefix, homeCluster);
+export const login = (uuidPrefix: string, homeCluster: string, remoteHosts: { [key: string]: string }) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ services.authService.login(uuidPrefix, homeCluster, remoteHosts);
dispatch(authActions.LOGIN());
};
<Typography component="div" align="right">
<Button variant="contained" color="primary" style={{ margin: "1em" }} className={classes.button}
- onClick={() => dispatch(login(uuidPrefix, remoteHosts[homeCluster]))}>
+ onClick={() => dispatch(login(uuidPrefix, homeCluster, remoteHosts))}>
Log in to {uuidPrefix}
{uuidPrefix !== homeCluster &&
<span> with user from {homeCluster}</span>}