-export const LoginPanel = withStyles(styles)(connect()(
- ({ classes, dispatch }: LoginPanelProps) =>
- <Grid container direction="column" item xs alignItems="center" justify="center" className={classes.root}>
- <Grid item className={classes.container}>
- <Typography variant="title" align="center" className={classes.title}>
- Welcome to the Arvados Workbench
- </Typography>
- <Typography variant="body1" className={classes.content}>
- The "Log in" button below will show you a Google sign-in page.
- After you assure Google that you want to log in here with your Google account, you will be redirected back here to Arvados Workbench.
- </Typography>
- <Typography variant="body1" className={classes.content}>
- If you have never used Arvados Workbench before, logging in for the first time will automatically create a new account.
- </Typography>
- <Typography variant="body2" className={classNames(classes.content, classes.content__bolder)}>
- IMPORTANT: Please keep in mind to store exploratory data only but not any information used for clinical decision making.
- </Typography>
- <Typography variant="body1" className={classes.content}>
- Arvados Workbench uses your name and email address only for identification, and does not retrieve any other personal information from Google.
- </Typography>
- <Typography component="div" align="right">
- <Button variant="contained" color="primary" className={classes.button} onClick={() => dispatch(login())}>
- Log in
- </Button>
- </Typography>
- </Grid>
- </Grid>
-));
+type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
+ remoteHosts: { [key: string]: string },
+ homeCluster: string,
+ localCluster: string,
+ loginCluster: string,
+ welcomePage: string,
+ passwordLogin: boolean,
+};
+
+const loginOptions = ['LDAP', 'PAM', 'Test'];
+
+export const requirePasswordLogin = (config: Config): boolean => {
+ if (config && config.clusterConfig && config.clusterConfig.Login) {
+ return loginOptions
+ .filter(loginOption => !!config.clusterConfig.Login[loginOption])
+ .map(loginOption => config.clusterConfig.Login[loginOption].Enable)
+ .find(enabled => enabled === true) || false;
+ }
+ return false;
+};
+
+export const LoginPanel = withStyles(styles)(
+ connect((state: RootState) => ({
+ remoteHosts: state.auth.remoteHosts,
+ homeCluster: state.auth.homeCluster,
+ localCluster: state.auth.localCluster,
+ loginCluster: state.auth.loginCluster,
+ welcomePage: state.auth.config.clusterConfig.Workbench.WelcomePageHTML,
+ passwordLogin: requirePasswordLogin(state.auth.remoteHostsConfig[state.auth.loginCluster || state.auth.homeCluster]),
+ }))(({ classes, dispatch, remoteHosts, homeCluster, localCluster, loginCluster, welcomePage, passwordLogin }: LoginPanelProps) => {
+ const loginBtnLabel = `Log in${(localCluster !== homeCluster && loginCluster !== homeCluster) ? " to "+localCluster+" with user from "+homeCluster : ''}`;
+
+ return (<Grid container justify="center" alignItems="center"
+ className={classes.root}
+ style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
+ <Grid item className={classes.container}>
+ <Typography component="div">
+ <div dangerouslySetInnerHTML={{ __html: welcomePage }} style={{ margin: "1em" }} />
+ </Typography>
+ {Object.keys(remoteHosts).length > 1 && loginCluster === "" &&
+
+ <Typography component="div" align="right">
+ <label>Please select the cluster that hosts your user account:</label>
+ <Select native value={homeCluster} style={{ margin: "1em" }}
+ onChange={(event) => dispatch(authActions.SET_HOME_CLUSTER(event.target.value))}>
+ {Object.keys(remoteHosts).map((k) => <option key={k} value={k}>{k}</option>)}
+ </Select>
+ </Typography>}
+
+ {passwordLogin
+ ? <Typography component="div">
+ <LoginForm dispatch={dispatch}
+ loginLabel={loginBtnLabel}
+ handleSubmit={doPasswordLogin(`https://${remoteHosts[loginCluster || homeCluster]}`)}/>
+ </Typography>
+ : <Typography component="div" align="right">
+ <Button variant="contained" color="primary" style={{ margin: "1em" }}
+ className={classes.button}
+ onClick={() => dispatch(login(localCluster, homeCluster, loginCluster, remoteHosts))}>
+ {loginBtnLabel}
+ </Button>
+ </Typography>}
+ </Grid>
+ </Grid >);}
+ ));