From 1d579f20e3ab364e7c8e420e3bd5c3000b6dfc87 Mon Sep 17 00:00:00 2001 From: garronej Date: Wed, 8 Mar 2023 23:17:40 +0100 Subject: [PATCH 1/2] Add RegisterUserProfile customization --- package.json | 4 +- src/keycloak-theme/KcApp.tsx | 2 + .../pages/RegisterUserProfile.tsx | 61 ++++++ .../pages/shared/UserProfileCommons.tsx | 176 ++++++++++++++++++ yarn.lock | 10 +- 5 files changed, 246 insertions(+), 7 deletions(-) create mode 100644 src/keycloak-theme/pages/RegisterUserProfile.tsx create mode 100644 src/keycloak-theme/pages/shared/UserProfileCommons.tsx diff --git a/package.json b/package.json index cc9c07c..ec574af 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "keycloakify-starter", "homepage": "https://starter.keycloakify.dev", - "version": "3.0.0", + "version": "3.1.0", "description": "A starter/demo project for keycloakify", "repository": { "type": "git", @@ -26,7 +26,7 @@ "evt": "^2.4.15", "jwt-decode": "^3.1.2", "keycloak-js": "^21.0.1", - "keycloakify": "^6.12.4", + "keycloakify": "^6.12.7", "powerhooks": "^0.26.2", "react": "18.1.0", "react-dom": "18.1.0", diff --git a/src/keycloak-theme/KcApp.tsx b/src/keycloak-theme/KcApp.tsx index efe0cf6..e7f8a0c 100644 --- a/src/keycloak-theme/KcApp.tsx +++ b/src/keycloak-theme/KcApp.tsx @@ -12,6 +12,7 @@ console.log(`Values passed by the main app in the URL parameter:`, { foo, bar }) const Login = lazy(()=> import("./pages/Login")); // If you can, favor register-user-profile.ftl over register.ftl, see: https://docs.keycloakify.dev/realtime-input-validation const Register = lazy(() => import("./pages/Register")); +const RegisterUserProfile = lazy(() => import("./pages/RegisterUserProfile")); const Terms = lazy(() => import("./pages/Terms")); const MyExtraPage1 = lazy(() => import("./pages/MyExtraPage1")); const MyExtraPage2 = lazy(() => import("./pages/MyExtraPage2")); @@ -61,6 +62,7 @@ export default function App(props: { kcContext: KcContext; }) { switch (kcContext.pageId) { case "login.ftl": return ; case "register.ftl": return ; + case "register-user-profile.ftl": return case "terms.ftl": return ; case "my-extra-page-1.ftl": return ; case "my-extra-page-2.ftl": return ; diff --git a/src/keycloak-theme/pages/RegisterUserProfile.tsx b/src/keycloak-theme/pages/RegisterUserProfile.tsx new file mode 100644 index 0000000..492e82b --- /dev/null +++ b/src/keycloak-theme/pages/RegisterUserProfile.tsx @@ -0,0 +1,61 @@ +// Copy pasted from: https://github.com/InseeFrLab/keycloakify/blob/main/src/lib/pages/RegisterUserProfile.tsx +import { useState } from "react"; +import { clsx } from "keycloakify/lib/tools/clsx"; +import { UserProfileFormFields } from "./shared/UserProfileCommons"; +import type { PageProps } from "keycloakify/lib/KcProps"; +import type { KcContext } from "../kcContext"; +import type { I18n } from "../i18n"; + +export default function RegisterUserProfile(props: PageProps, I18n>) { + const { kcContext, i18n, doFetchDefaultThemeResources = true, Template, ...kcProps } = props; + + const { url, messagesPerField, recaptchaRequired, recaptchaSiteKey } = kcContext; + + const { msg, msgStr } = i18n; + + const [isFomSubmittable, setIsFomSubmittable] = useState(false); + + return ( +