Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/login/KcPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Login = lazy(() => import("./pages/Login"));
const Register = lazy(() => import("./pages/Register"));
const LoginUpdateProfile = lazy(() => import("./pages/LoginUpdateProfile"));
const LoginUpdatePassword = lazy(() => import("./pages/LoginUpdatePassword"));
const LoginVerifyEmail = lazy(() => import("./pages/LoginVerifyEmail"));

const doMakeUserConfirmPassword = false;

Expand Down Expand Up @@ -77,6 +78,14 @@ export default function KcPage(props: { kcContext: KcContext }) {
doUseDefaultCss={false}
/>
);
case "login-verify-email.ftl":
return (
<LoginVerifyEmail
{...{ kcContext, i18n, classes }}
Template={Template}
doUseDefaultCss={false}
/>
);
default:
return (
<DefaultPage
Expand Down
43 changes: 43 additions & 0 deletions src/login/pages/LoginVerifyEmail.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { Meta, StoryObj } from "@storybook/react";
import { createKcPageStory } from "../KcPageStory";

const { KcPageStory } = createKcPageStory({ pageId: "login-verify-email.ftl" });

const meta = {
title: "login/login-verify-email.ftl",
component: KcPageStory
} satisfies Meta<typeof KcPageStory>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
render: () => (
<KcPageStory
kcContext={{
user: {
email: "user@example.com"
}
}}
/>
)
};

/**
* WithCustomEmail:
* - Purpose: Tests the page with a specific email address.
* - Scenario: Simulates a user with a custom email address to verify the display.
* - Key Aspect: Ensures the email is correctly displayed in the verification message.
*/
export const WithCustomEmail: Story = {
render: () => (
<KcPageStory
kcContext={{
user: {
email: "thais@hubee.com"
}
}}
/>
)
};
64 changes: 64 additions & 0 deletions src/login/pages/LoginVerifyEmail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { getKcClsx } from "keycloakify/login/lib/kcClsx";
import type { PageProps } from "keycloakify/login/pages/PageProps";
import type { KcContext } from "../KcContext";
import type { I18n } from "../i18n";
import Alert from "@codegouvfr/react-dsfr/Alert";
import { fr } from "@codegouvfr/react-dsfr";

export default function LoginVerifyEmail(props: PageProps<Extract<KcContext, { pageId: "login-verify-email.ftl" }>, I18n>) {
const { kcContext, i18n, doUseDefaultCss, Template, classes } = props;

const { kcClsx } = getKcClsx({
doUseDefaultCss,
classes
});

const { url, user } = kcContext;

const { msg, msgStr } = i18n;

return (
<Template
kcContext={kcContext}
i18n={i18n}
doUseDefaultCss={doUseDefaultCss}
classes={classes}
displayMessage={false}
headerNode={msg("emailVerifyTitle")}
>
<Alert
severity="info"
description={msgStr("emailVerifyInstruction1", user?.email ?? "")}
className={fr.cx("fr-mb-4w")}
small
/>

<div className={kcClsx("kcFormGroupClass")}>
<p className={fr.cx("fr-text--sm", "fr-mb-3w")}>
{msgStr("emailVerifyInstruction2")}{" "}
<form action={url.loginAction} method="post" style={{ display: "inline" }}>
<input type="hidden" name="email" value={user?.email ?? ""} />
<button
type="submit"
className={fr.cx("fr-link")}
style={{
background: "none",
border: "none",
padding: 0,
cursor: "pointer"
}}
>
{msgStr("doClickHere")} {msgStr("emailVerifyInstruction3")}
</button>
</form>
</p>
</div>

<div className={kcClsx("kcFormGroupClass")} style={{ display: "flex", justifyContent: "flex-end" }}>
<a className={fr.cx("fr-link")} href={url.loginUrl}>
{msg("backToLogin")}
</a>
</div>
</Template>
);
}