Skip to content

Commit

Permalink
✨ - feat: Add possibility for OIDC login [maykinmedia/open-archiefbeh…
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Oct 2, 2024
1 parent 93623aa commit 029c5df
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/contexts/config/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export type ConfigContextType = {

/** Overrides the logo throughout this library. */
logo?: React.ReactNode;

oidcLoginUrl?: string;
};

/**
Expand Down
27 changes: 24 additions & 3 deletions src/templates/login/login.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import React, { useContext } from "react";

import { Body, Card, Form, FormProps, Hr, Logo } from "../../components";
import {
Body, // Button,
// ButtonLink,
Card,
Form,
FormProps,
Hr,
Logo,
} from "../../components";
import { ConfigContext } from "../../contexts";
import { ucFirst } from "../../lib/format/string";
import { useIntl } from "../../lib/i18n/useIntl";
Expand All @@ -17,6 +25,8 @@ export type LoginTemplateProps = BaseTemplateProps & {

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

labelOidcLogin?: string;
};

/**
Expand All @@ -26,10 +36,11 @@ export type LoginTemplateProps = BaseTemplateProps & {
export const LoginTemplate: React.FC<LoginTemplateProps> = ({
formProps,
labelLogin,
labelOidcLogin,
slotLogo,
...props
}) => {
const { logo: CustomLogo } = useContext(ConfigContext);
const { logo: CustomLogo, oidcLoginUrl } = useContext(ConfigContext);
const intl = useIntl();

const _labelLogin = labelLogin
Expand All @@ -51,7 +62,17 @@ export const LoginTemplate: React.FC<LoginTemplateProps> = ({
<Body>
{slotLogo || CustomLogo || <Logo />}
<Hr />
<Form labelSubmit={ucFirst(_labelLogin)} {...formProps} />
<Form
labelSubmit={ucFirst(_labelLogin)}
secondaryActions={[
{
href: oidcLoginUrl,
variant: "secondary",
children: labelOidcLogin || "OIDC Login",
},
]}
{...formProps}
/>
</Body>
</Card>
</BaseTemplate>
Expand Down

0 comments on commit 029c5df

Please sign in to comment.