Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for OIDC login #138

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 20 additions & 0 deletions src/templates/login/login.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,23 @@ export const loginTemplate: Story = {
labelLogin: "Log in",
},
};

export const WithOIDC: Story = {
args: {
formProps: {
autoComplete: "off",
fields: [
{
label: "Gebruikersnaam",
name: "username",
},
{
label: "Wachtwoord",
name: "Password",
},
],
},
urlOidcLogin: "http://example.nl/oidc/authenticate/",
labelOidcLogin: "OIDC Login!",
},
};
27 changes: 26 additions & 1 deletion src/templates/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export type LoginTemplateProps = BaseTemplateProps & {

/** Logo (JSX) slot. */
slotLogo?: React.ReactNode;

labelOidcLogin?: string;
urlOidcLogin?: string;
};

/**
Expand All @@ -26,6 +29,8 @@ export type LoginTemplateProps = BaseTemplateProps & {
export const LoginTemplate: React.FC<LoginTemplateProps> = ({
formProps,
labelLogin,
labelOidcLogin,
urlOidcLogin,
slotLogo,
...props
}) => {
Expand All @@ -40,6 +45,22 @@ export const LoginTemplate: React.FC<LoginTemplateProps> = ({
defaultMessage: "inloggen",
});

const _labelOidcLogin = labelOidcLogin
? labelOidcLogin
: intl.formatMessage({
id: "mykn.templates.Login.labelOidcLogin",
description: "templates.Login: The label for the OIDC login button.",
defaultMessage: "OIDC Login",
SilviaAmAm marked this conversation as resolved.
Show resolved Hide resolved
});

const secondaryActions = [];
if (urlOidcLogin)
secondaryActions.push({
href: urlOidcLogin,
variant: "secondary",
children: _labelOidcLogin,
});

return (
<BaseTemplate
columnProps={{ start: 5, span: 4 }}
Expand All @@ -51,7 +72,11 @@ export const LoginTemplate: React.FC<LoginTemplateProps> = ({
<Body>
{slotLogo || CustomLogo || <Logo />}
<Hr />
<Form labelSubmit={ucFirst(_labelLogin)} {...formProps} />
<Form
labelSubmit={ucFirst(_labelLogin)}
secondaryActions={secondaryActions}
{...formProps}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if it should be possible to overrule the default login and only allow OIDC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know! But could be useful 🤔

/>
</Body>
</Card>
</BaseTemplate>
Expand Down