diff --git a/src/login/KcPage.tsx b/src/login/KcPage.tsx index e50b5307..2d4da1bc 100644 --- a/src/login/KcPage.tsx +++ b/src/login/KcPage.tsx @@ -13,10 +13,13 @@ 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 Error = lazy(() => import("./pages/Error")); const LoginResetPassword = lazy(() => import("./pages/LoginResetPassword")); const LoginPageExpired = lazy(() => import("./pages/LoginPageExpired")); const LoginVerifyEmail = lazy(() => import("./pages/LoginVerifyEmail")); + const doMakeUserConfirmPassword = false; export default function KcPage(props: { kcContext: KcContext }) { @@ -80,6 +83,14 @@ export default function KcPage(props: { kcContext: KcContext }) { doUseDefaultCss={false} /> ); + case "error.ftl": + return ( + + ); case "login-reset-password.ftl": return ( ; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + render: () => ( + + ) +}; + +/** + * AccountLocked: + * - Purpose: Tests the error page for account lockout scenarios. + * - Scenario: Simulates a user whose account has been locked due to too many failed login attempts. + * - Key Aspect: Displays a specific error message about account lockout. + */ +export const AccountLocked: Story = { + render: () => ( + + ) +}; + +/** + * WithClientBaseUrl: + * - Purpose: Tests the error page when a client base URL is available. + * - Scenario: Simulates an error with the option to return to the application. + * - Key Aspect: Displays a "Back to Application" button in addition to "Back to Login". + */ +export const WithClientBaseUrl: Story = { + render: () => ( + + ) +}; diff --git a/src/login/pages/Error.tsx b/src/login/pages/Error.tsx new file mode 100644 index 00000000..45abaab7 --- /dev/null +++ b/src/login/pages/Error.tsx @@ -0,0 +1,49 @@ +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 Error(props: PageProps, I18n>) { + const { kcContext, i18n, doUseDefaultCss, Template, classes } = props; + + const { kcClsx } = getKcClsx({ + doUseDefaultCss, + classes + }); + + const { url, message, client } = kcContext; + + const { msg } = i18n; + + return ( + + + + + {client.baseUrl !== undefined ? ( + + {msg("backToApplication")} + + ) : ( + + {msg("backToLogin")} + + )} + + + ); +}