Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/WrapperApp/components/Login/LoginPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import NamePasswordLoginPanel from './NamePasswordLoginPanel';

export default function LoginPanel() {
const theme = useTheme();
const { altAuth } = useConfig();
const { altAuth, useBasicAuth } = useConfig();
const { keycloak, initialized } = useKeycloakAuth();
const [namePasswordLogin, setNamePasswordLogin] = useState(!altAuth);

const keycloakLogin = useCallback(() => {
if (initialized && !keycloak.authenticated) keycloak.login();
}, [initialized, keycloak]);

const showPasswordLogin = useBasicAuth;

return (
<Box
sx={{
Expand Down Expand Up @@ -51,12 +53,14 @@ export default function LoginPanel() {
}}>
Connect with PLGrid
</Button>
<Link
color='textDisabled'
onClick={() => setNamePasswordLogin(true)}
sx={{ cursor: 'pointer' }}>
use password login
</Link>
{showPasswordLogin && (
<Link
color='textDisabled'
onClick={() => setNamePasswordLogin(true)}
sx={{ cursor: 'pointer' }}>
use password login
</Link>
)}
</>
) : (
<>
Expand Down
6 changes: 5 additions & 1 deletion src/config/ConfigService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { snakeToCamelCase } from '../util/Notation/Notation';
const BACKEND_URL = process.env.REACT_APP_BACKEND_URL ?? 'http://localhost:5000';
const DEMO_MODE = process.env.REACT_APP_TARGET === 'demo';
const ALT_AUTH = process.env.REACT_APP_ALT_AUTH === 'plg';
const USE_BASIC_AUTH = process.env.REACT_APP_USE_BASIC_AUTH === 'true';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by "basic auth" ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take a look at the discussion here:
https://gist.github.com/grzanka/4c71da7a1794c2c109f2d51f3d0189aa

you could use this PR for a more general cleaning


export const DEPLOYMENT = (process.env.REACT_APP_DEPLOYMENT as ConfigDeployment) ?? 'prod';
export type ConfigDeployment = 'dev' | 'prod' | undefined;
Expand All @@ -18,6 +19,7 @@ interface Config {
deployment: ConfigDeployment;
demoMode: boolean;
altAuth: boolean;
useBasicAuth: boolean;
}

declare global {
Expand All @@ -36,7 +38,8 @@ const ConfigProvider = ({ children }: { children?: ReactNode }) => {
backendUrl: BACKEND_URL,
deployment: DEPLOYMENT,
demoMode: DEMO_MODE,
altAuth: ALT_AUTH
altAuth: ALT_AUTH,
useBasicAuth: USE_BASIC_AUTH
});
window.BACKEND_URL ??= BACKEND_URL;

Expand Down Expand Up @@ -75,6 +78,7 @@ const ConfigProvider = ({ children }: { children?: ReactNode }) => {
defineProperty('DEPLOYMENT', true);
defineProperty('DEMO_MODE');
defineProperty('ALT_AUTH');
defineProperty('USE_BASIC_AUTH');
}
}, [config]);

Expand Down
Loading