From 2a10ec9a2063c263911cf8b33ae3f256485daa99 Mon Sep 17 00:00:00 2001 From: garronej Date: Wed, 7 Sep 2022 13:27:27 +0200 Subject: [PATCH] WIP --- package.json | 2 +- src/KcApp/KcApp.tsx | 3 + src/KcApp/MyExtraPage1.tsx | 14 ++++ src/KcApp/MyExtraPage2.tsx | 16 ++++ src/KcApp/Register.tsx | 168 +++++++++++++++++++++++++++++++++++++ src/KcApp/kcContext.ts | 2 +- yarn.lock | 17 +++- 7 files changed, 216 insertions(+), 6 deletions(-) create mode 100644 src/KcApp/MyExtraPage1.tsx create mode 100644 src/KcApp/MyExtraPage2.tsx create mode 100644 src/KcApp/Register.tsx diff --git a/package.json b/package.json index 8a24f90..88e8464 100755 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "keywords": [], "dependencies": { "@emotion/react": "^11.9.0", - "keycloakify": "^6.0.0", + "keycloakify": "^6.0.2", "react": "18.1.0", "react-dom": "18.1.0", "evt": "^2.4.1" diff --git a/src/KcApp/KcApp.tsx b/src/KcApp/KcApp.tsx index 1f5ea8e..a242f2b 100644 --- a/src/KcApp/KcApp.tsx +++ b/src/KcApp/KcApp.tsx @@ -3,7 +3,10 @@ import type { KcContext } from "./kcContext"; import KcAppBase, { defaultKcProps } from "keycloakify"; import { useI18n } from "./i18n"; +const Register = lazy(() => import("./Register")); const Terms = lazy(() => import("./Terms")); +const MyExtraPage1 = lazy(() => import("./MyExtraPage1")); +const MyExtraPage2 = lazy(() => import("./MyExtraPage2")); export type Props = { kcContext: KcContext; diff --git a/src/KcApp/MyExtraPage1.tsx b/src/KcApp/MyExtraPage1.tsx new file mode 100644 index 0000000..1650449 --- /dev/null +++ b/src/KcApp/MyExtraPage1.tsx @@ -0,0 +1,14 @@ +import { memo } from "react"; +import type { KcProps } from "keycloakify"; +import type { KcContext } from "./kcContext"; +import type { I18n } from "./i18n"; + +type KcContext_MyExtraPage1 = Extract; + +const MyExtraPage1 = memo(({ kcContext, i18n, ...props }: { kcContext: KcContext_MyExtraPage1; i18n: I18n; } & KcProps) => { + + return <>It is up to you to implement this page + +}); + +export default MyExtraPage1; \ No newline at end of file diff --git a/src/KcApp/MyExtraPage2.tsx b/src/KcApp/MyExtraPage2.tsx new file mode 100644 index 0000000..ecdd333 --- /dev/null +++ b/src/KcApp/MyExtraPage2.tsx @@ -0,0 +1,16 @@ +import { memo } from "react"; +import type { KcProps } from "keycloakify"; +import type { KcContext } from "./kcContext"; +import type { I18n } from "./i18n"; + +type KcContext_MyExtraPage2 = Extract; + +const MyExtraPage2 = memo(({ kcContext, i18n, ...props }: { kcContext: KcContext_MyExtraPage2; i18n: I18n; } & KcProps) => { + + console.log(`TODO: Do something with: ${kcContext.someCustomValue}`); + + return <>It is up to you to implement this page + +}); + +export default MyExtraPage2; \ No newline at end of file diff --git a/src/KcApp/Register.tsx b/src/KcApp/Register.tsx new file mode 100644 index 0000000..bad7a07 --- /dev/null +++ b/src/KcApp/Register.tsx @@ -0,0 +1,168 @@ +// This is a copy paste from https://github.com/InseeFrLab/keycloakify/blob/main/src/lib/components/Register.tsx +// It is now up to us to implement a special behavior to leverage the non standard authorizedMailDomains +// provided by the plugin: https://github.com/micedre/keycloak-mail-whitelisting installed on our keycloak server. +// Note that it is no longer recommended to use register.ftl, it's best to use register-user-profile.ftl +// See: https://docs.keycloakify.dev/realtime-input-validation + +import { memo } from "react"; +import Template from "keycloakify/lib/components/Template"; +import type { KcProps } from "keycloakify"; +import type { KcContext } from "./kcContext"; +import { useCssAndCx } from "keycloakify/lib/tools/useCssAndCx"; +import type { I18n } from "./i18n"; + +type KcContext_Register = Extract; + +const Register = memo(({ kcContext, i18n, ...props }: { kcContext: KcContext_Register; i18n: I18n; } & KcProps) => { + const { url, messagesPerField, register, realm, passwordRequired, recaptchaRequired, recaptchaSiteKey } = kcContext; + + const { msg, msgStr } = i18n; + + const { cx } = useCssAndCx(); + + console.log(`NOTE: It is up to you do do something meaningful with ${kcContext.authorizedMailDomains}`) + + return ( +