X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/ca7a29e2ac03703afeff3248d1b909f42b89ab19..d861bd54089e9279cd03b2e4561869ee877b9559:/src/views/login-panel/login-panel.tsx

diff --git a/src/views/login-panel/login-panel.tsx b/src/views/login-panel/login-panel.tsx
index f60f032a..110097be 100644
--- a/src/views/login-panel/login-panel.tsx
+++ b/src/views/login-panel/login-panel.tsx
@@ -2,16 +2,16 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import { connect, DispatchProp } from 'react-redux';
 import { Grid, Typography, Button, Select } from '@material-ui/core';
 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
-import { login, authActions } from '~/store/auth/auth-action';
-import { ArvadosTheme } from '~/common/custom-theme';
-import { RootState } from '~/store/store';
-import { LoginForm } from '~/views-components/login-form/login-form';
+import { login, authActions } from 'store/auth/auth-action';
+import { ArvadosTheme } from 'common/custom-theme';
+import { RootState } from 'store/store';
+import { LoginForm } from 'views-components/login-form/login-form';
 import Axios from 'axios';
-import { Config } from '~/common/config';
+import { Config } from 'common/config';
 
 type CssRules = 'root' | 'container' | 'title' | 'content' | 'content__bolder' | 'button';
 
@@ -51,7 +51,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 });
 
 const doPasswordLogin = (url: string) => (username: string, password: string) => {
-    const formData = [];
+    const formData: string[] = [];
     formData.push('username='+encodeURIComponent(username));
     formData.push('password='+encodeURIComponent(password));
     return Axios.post(`${url}/arvados/v1/users/authenticate`, formData.join('&'), {
@@ -70,9 +70,14 @@ type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
     passwordLogin: boolean,
 };
 
-const requirePasswordLogin = (config: Config): boolean => {
-    if (config && config.clusterConfig) {
-        return config.clusterConfig.Login.LDAP.Enable || config.clusterConfig.Login.PAM.Enable || false;
+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;
 };
