@oussemasahbeni/keycloakify-login-shadcn 250004.0.3 → 250004.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/keycloak-theme/components/langauges.tsx +1 -1
  2. package/keycloak-theme/components/theme-toggle.tsx +0 -1
  3. package/keycloak-theme/components/ui/alert.tsx +1 -2
  4. package/keycloak-theme/components/ui/button.tsx +1 -2
  5. package/keycloak-theme/components/ui/card.tsx +0 -1
  6. package/keycloak-theme/components/ui/checkbox.tsx +0 -1
  7. package/keycloak-theme/components/ui/dropdown-menu.tsx +14 -4
  8. package/keycloak-theme/components/ui/field.tsx +0 -1
  9. package/keycloak-theme/components/ui/input-otp.tsx +0 -1
  10. package/keycloak-theme/components/ui/input.tsx +0 -1
  11. package/keycloak-theme/components/ui/label.tsx +1 -2
  12. package/keycloak-theme/components/ui/radio-group.tsx +0 -1
  13. package/keycloak-theme/components/ui/select.tsx +12 -4
  14. package/keycloak-theme/components/ui/separator.tsx +0 -1
  15. package/keycloak-theme/components/ui/tooltip.tsx +0 -1
  16. package/keycloak-theme/login/KcContext.ts +23 -23
  17. package/keycloak-theme/login/KcPage.tsx +45 -47
  18. package/keycloak-theme/login/assets/img/auth-logo.svg +100 -100
  19. package/keycloak-theme/login/assets/img/shape.svg +71 -71
  20. package/keycloak-theme/login/components/LogoutOtherSessions.tsx +24 -26
  21. package/keycloak-theme/login/components/PasswordWrapper.tsx +35 -35
  22. package/keycloak-theme/login/components/Template/Template.tsx +279 -227
  23. package/keycloak-theme/login/components/Template/index.ts +1 -1
  24. package/keycloak-theme/login/components/Template/useInitializeTemplate.ts +61 -61
  25. package/keycloak-theme/login/components/UserProfileFormFields/AddRemoveButtonsMultiValuedAttribute.tsx +65 -61
  26. package/keycloak-theme/login/components/UserProfileFormFields/DO_MAKE_USER_CONFIRM_PASSWORD.ts +2 -2
  27. package/keycloak-theme/login/components/UserProfileFormFields/FieldErrors.tsx +33 -29
  28. package/keycloak-theme/login/components/UserProfileFormFields/GroupLabel.tsx +90 -71
  29. package/keycloak-theme/login/components/UserProfileFormFields/InputFieldByType.tsx +66 -59
  30. package/keycloak-theme/login/components/UserProfileFormFields/InputLabel.tsx +0 -1
  31. package/keycloak-theme/login/components/UserProfileFormFields/InputTag.tsx +133 -116
  32. package/keycloak-theme/login/components/UserProfileFormFields/InputTagSelects.tsx +150 -136
  33. package/keycloak-theme/login/components/UserProfileFormFields/SelectTag.tsx +135 -114
  34. package/keycloak-theme/login/components/UserProfileFormFields/TextareaTag.tsx +55 -43
  35. package/keycloak-theme/login/components/UserProfileFormFields/UserProfileFormFields.tsx +133 -127
  36. package/keycloak-theme/login/components/UserProfileFormFields/index.ts +1 -1
  37. package/keycloak-theme/login/i18n.ts +47 -47
  38. package/keycloak-theme/login/mocks/KcPageStory.tsx +6 -2
  39. package/keycloak-theme/login/mocks/getKcContextMock.ts +22 -22
  40. package/keycloak-theme/login/pages/PageIndex.tsx +130 -134
  41. package/keycloak-theme/login/pages/code/Page.stories.tsx +57 -70
  42. package/keycloak-theme/login/pages/code/Page.tsx +89 -89
  43. package/keycloak-theme/login/pages/code/index.ts +3 -3
  44. package/keycloak-theme/login/pages/delete-account-confirm/Page.stories.tsx +37 -46
  45. package/keycloak-theme/login/pages/delete-account-confirm/Page.tsx +60 -63
  46. package/keycloak-theme/login/pages/delete-account-confirm/index.ts +3 -3
  47. package/keycloak-theme/login/pages/delete-credential/Page.stories.tsx +25 -30
  48. package/keycloak-theme/login/pages/delete-credential/Page.tsx +56 -51
  49. package/keycloak-theme/login/pages/delete-credential/index.ts +3 -3
  50. package/keycloak-theme/login/pages/error/Page.stories.tsx +46 -58
  51. package/keycloak-theme/login/pages/error/Page.tsx +43 -42
  52. package/keycloak-theme/login/pages/error/index.ts +3 -3
  53. package/keycloak-theme/login/pages/frontchannel-logout/Page.stories.tsx +25 -32
  54. package/keycloak-theme/login/pages/frontchannel-logout/Page.tsx +82 -84
  55. package/keycloak-theme/login/pages/frontchannel-logout/index.ts +3 -3
  56. package/keycloak-theme/login/pages/idp-review-user-profile/Page.stories.tsx +46 -59
  57. package/keycloak-theme/login/pages/idp-review-user-profile/Page.tsx +49 -52
  58. package/keycloak-theme/login/pages/idp-review-user-profile/index.ts +3 -3
  59. package/keycloak-theme/login/pages/info/Page.stories.tsx +50 -60
  60. package/keycloak-theme/login/pages/info/Page.tsx +94 -92
  61. package/keycloak-theme/login/pages/link-idp-action/Page.stories.tsx +32 -16
  62. package/keycloak-theme/login/pages/link-idp-action/Page.tsx +45 -43
  63. package/keycloak-theme/login/pages/link-idp-action/index.ts +3 -3
  64. package/keycloak-theme/login/pages/login/Form.tsx +242 -242
  65. package/keycloak-theme/login/pages/login/Info.tsx +29 -29
  66. package/keycloak-theme/login/pages/login/Page.stories.tsx +346 -365
  67. package/keycloak-theme/login/pages/login/Page.tsx +43 -44
  68. package/keycloak-theme/login/pages/login/SocialProviders.tsx +93 -107
  69. package/keycloak-theme/login/pages/login/index.ts +3 -3
  70. package/keycloak-theme/login/pages/login/providers/apple.svg +3 -3
  71. package/keycloak-theme/login/pages/login/providers/bitbucket.svg +11 -11
  72. package/keycloak-theme/login/pages/login/providers/discord.svg +4 -4
  73. package/keycloak-theme/login/pages/login/providers/facebook.svg +5 -5
  74. package/keycloak-theme/login/pages/login/providers/github.svg +3 -3
  75. package/keycloak-theme/login/pages/login/providers/gitlab.svg +7 -7
  76. package/keycloak-theme/login/pages/login/providers/google.svg +7 -7
  77. package/keycloak-theme/login/pages/login/providers/instagram.svg +31 -31
  78. package/keycloak-theme/login/pages/login/providers/linkedin.svg +3 -3
  79. package/keycloak-theme/login/pages/login/providers/microsoft.svg +6 -6
  80. package/keycloak-theme/login/pages/login/providers/oidc.svg +5 -5
  81. package/keycloak-theme/login/pages/login/providers/openshift.svg +7 -7
  82. package/keycloak-theme/login/pages/login/providers/paypal.svg +6 -6
  83. package/keycloak-theme/login/pages/login/providers/slack.svg +11 -11
  84. package/keycloak-theme/login/pages/login/providers/stackoverflow.svg +5 -5
  85. package/keycloak-theme/login/pages/login/providers/x.svg +3 -3
  86. package/keycloak-theme/login/pages/login/useProviderLogos.tsx +39 -39
  87. package/keycloak-theme/login/pages/login/useScript.tsx +62 -62
  88. package/keycloak-theme/login/pages/login-config-totp/Page.stories.tsx +45 -60
  89. package/keycloak-theme/login/pages/login-config-totp/Page.tsx +253 -240
  90. package/keycloak-theme/login/pages/login-config-totp/index.ts +3 -3
  91. package/keycloak-theme/login/pages/login-idp-link-confirm/Page.stories.tsx +30 -35
  92. package/keycloak-theme/login/pages/login-idp-link-confirm/Page.tsx +40 -43
  93. package/keycloak-theme/login/pages/login-idp-link-confirm/index.ts +3 -3
  94. package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.stories.tsx +16 -23
  95. package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.tsx +44 -47
  96. package/keycloak-theme/login/pages/login-idp-link-confirm-override/index.ts +3 -3
  97. package/keycloak-theme/login/pages/login-idp-link-email/Page.stories.tsx +54 -63
  98. package/keycloak-theme/login/pages/login-idp-link-email/Page.tsx +51 -54
  99. package/keycloak-theme/login/pages/login-idp-link-email/index.ts +3 -3
  100. package/keycloak-theme/login/pages/login-oauth-grant/Page.stories.tsx +39 -45
  101. package/keycloak-theme/login/pages/login-oauth-grant/Page.tsx +136 -126
  102. package/keycloak-theme/login/pages/login-oauth-grant/index.ts +3 -3
  103. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.stories.tsx +38 -48
  104. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.tsx +56 -58
  105. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/index.ts +3 -3
  106. package/keycloak-theme/login/pages/login-otp/Page.stories.tsx +82 -97
  107. package/keycloak-theme/login/pages/login-otp/Page.tsx +117 -108
  108. package/keycloak-theme/login/pages/login-otp/index.ts +3 -3
  109. package/keycloak-theme/login/pages/login-page-expired/Page.stories.tsx +28 -37
  110. package/keycloak-theme/login/pages/login-page-expired/Page.tsx +45 -47
  111. package/keycloak-theme/login/pages/login-page-expired/index.ts +3 -3
  112. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.stories.tsx +20 -0
  113. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.tsx +290 -233
  114. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/index.ts +3 -3
  115. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/useScript.tsx +63 -63
  116. package/keycloak-theme/login/pages/login-password/Page.stories.tsx +55 -56
  117. package/keycloak-theme/login/pages/login-password/Page.tsx +148 -149
  118. package/keycloak-theme/login/pages/login-password/index.ts +3 -3
  119. package/keycloak-theme/login/pages/login-password/useScript.tsx +62 -63
  120. package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.stories.tsx +28 -36
  121. package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.tsx +178 -181
  122. package/keycloak-theme/login/pages/login-recovery-authn-code-config/index.ts +3 -3
  123. package/keycloak-theme/login/pages/login-recovery-authn-code-config/useScript.tsx +145 -145
  124. package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.stories.tsx +16 -22
  125. package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.tsx +69 -70
  126. package/keycloak-theme/login/pages/login-recovery-authn-code-input/index.ts +3 -3
  127. package/keycloak-theme/login/pages/login-reset-otp/Page.stories.tsx +62 -75
  128. package/keycloak-theme/login/pages/login-reset-otp/Page.tsx +85 -86
  129. package/keycloak-theme/login/pages/login-reset-otp/index.ts +3 -3
  130. package/keycloak-theme/login/pages/login-reset-password/Form.tsx +67 -68
  131. package/keycloak-theme/login/pages/login-reset-password/Page.stories.tsx +44 -55
  132. package/keycloak-theme/login/pages/login-reset-password/Page.tsx +27 -27
  133. package/keycloak-theme/login/pages/login-reset-password/index.ts +3 -3
  134. package/keycloak-theme/login/pages/login-update-password/Page.stories.tsx +40 -51
  135. package/keycloak-theme/login/pages/login-update-password/Page.tsx +109 -111
  136. package/keycloak-theme/login/pages/login-update-password/index.ts +3 -3
  137. package/keycloak-theme/login/pages/login-update-profile/Page.stories.tsx +28 -37
  138. package/keycloak-theme/login/pages/login-update-profile/Page.tsx +67 -68
  139. package/keycloak-theme/login/pages/login-update-profile/index.ts +3 -3
  140. package/keycloak-theme/login/pages/login-username/Page.stories.tsx +32 -43
  141. package/keycloak-theme/login/pages/login-username/Page.tsx +246 -246
  142. package/keycloak-theme/login/pages/login-username/index.ts +3 -3
  143. package/keycloak-theme/login/pages/login-username/useScript.tsx +62 -62
  144. package/keycloak-theme/login/pages/login-verify-email/Page.stories.tsx +68 -81
  145. package/keycloak-theme/login/pages/login-verify-email/Page.tsx +37 -38
  146. package/keycloak-theme/login/pages/login-verify-email/index.ts +3 -3
  147. package/keycloak-theme/login/pages/login-x509-info/Page.stories.tsx +29 -38
  148. package/keycloak-theme/login/pages/login-x509-info/Page.tsx +72 -75
  149. package/keycloak-theme/login/pages/login-x509-info/index.ts +3 -3
  150. package/keycloak-theme/login/pages/logout-confirm/Page.stories.tsx +34 -43
  151. package/keycloak-theme/login/pages/logout-confirm/Page.tsx +50 -53
  152. package/keycloak-theme/login/pages/logout-confirm/index.ts +3 -3
  153. package/keycloak-theme/login/pages/register/Form.tsx +107 -106
  154. package/keycloak-theme/login/pages/register/Page.stories.tsx +40 -14
  155. package/keycloak-theme/login/pages/register/Page.tsx +26 -26
  156. package/keycloak-theme/login/pages/register/TermsAcceptance.tsx +55 -56
  157. package/keycloak-theme/login/pages/register/index.ts +3 -3
  158. package/keycloak-theme/login/pages/saml-post-form/Page.stories.tsx +16 -23
  159. package/keycloak-theme/login/pages/saml-post-form/Page.tsx +64 -66
  160. package/keycloak-theme/login/pages/saml-post-form/index.ts +3 -3
  161. package/keycloak-theme/login/pages/select-authenticator/Page.stories.tsx +83 -96
  162. package/keycloak-theme/login/pages/select-authenticator/Page.tsx +97 -100
  163. package/keycloak-theme/login/pages/select-authenticator/index.ts +3 -3
  164. package/keycloak-theme/login/pages/select-organization/Page.stories.tsx +62 -49
  165. package/keycloak-theme/login/pages/select-organization/Page.tsx +123 -126
  166. package/keycloak-theme/login/pages/select-organization/index.ts +3 -3
  167. package/keycloak-theme/login/pages/terms/Page.stories.tsx +15 -0
  168. package/keycloak-theme/login/pages/terms/Page.tsx +49 -51
  169. package/keycloak-theme/login/pages/terms/index.ts +3 -3
  170. package/keycloak-theme/login/pages/update-email/Page.stories.tsx +27 -36
  171. package/keycloak-theme/login/pages/update-email/Page.tsx +61 -62
  172. package/keycloak-theme/login/pages/update-email/index.ts +3 -3
  173. package/keycloak-theme/login/pages/webauthn-authenticate/Page.stories.tsx +112 -127
  174. package/keycloak-theme/login/pages/webauthn-authenticate/Page.tsx +206 -202
  175. package/keycloak-theme/login/pages/webauthn-authenticate/index.ts +3 -3
  176. package/keycloak-theme/login/pages/webauthn-authenticate/useScript.tsx +55 -55
  177. package/keycloak-theme/login/pages/webauthn-error/Page.stories.tsx +52 -67
  178. package/keycloak-theme/login/pages/webauthn-error/Page.tsx +70 -73
  179. package/keycloak-theme/login/pages/webauthn-error/index.ts +3 -3
  180. package/keycloak-theme/login/pages/webauthn-register/Page.stories.tsx +39 -50
  181. package/keycloak-theme/login/pages/webauthn-register/Page.tsx +78 -78
  182. package/keycloak-theme/login/pages/webauthn-register/index.ts +3 -3
  183. package/keycloak-theme/login/pages/webauthn-register/useScript.tsx +62 -62
  184. package/keycloak-theme/login/shared/getColorScheme.ts +45 -45
  185. package/keycloak-theme/login/styleLevelCustomization.tsx +34 -36
  186. package/keycloak-theme/public/site.webmanifest +11 -1
  187. package/package.json +6 -2
@@ -1,63 +1,63 @@
1
- import { useInsertScriptTags } from "@keycloakify/login-ui/tools/useInsertScriptTags";
2
- import { waitForElementMountedOnDom } from "@keycloakify/login-ui/tools/waitForElementMountedOnDom";
3
- import { useEffect } from "react";
4
- import { assert } from "tsafe/assert";
5
-
6
- import { useI18n } from "../../i18n";
7
- import { useKcContext } from "../../KcContext";
8
-
9
- export function useScript(params: { webAuthnButtonId: string }) {
10
- const { webAuthnButtonId } = params;
11
-
12
- const { kcContext } = useKcContext();
13
- assert(kcContext.pageId === "login-passkeys-conditional-authenticate.ftl");
14
-
15
- const { msgStr, isFetchingTranslations } = useI18n();
16
-
17
- const { insertScriptTags } = useInsertScriptTags({
18
- effectId: "LoginRecoveryAuthnCodeConfig",
19
- scriptTags: [
20
- {
21
- type: "module",
22
- textContent: () => `
23
- import { authenticateByWebAuthn } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/webauthnAuthenticate.js";
24
- import { initAuthenticate } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/passkeysConditionalAuth.js";
25
-
26
- const authButton = document.getElementById("${webAuthnButtonId}");
27
- const input = {
28
- isUserIdentified : ${kcContext.isUserIdentified},
29
- challenge : ${JSON.stringify(kcContext.challenge)},
30
- userVerification : ${JSON.stringify(kcContext.userVerification)},
31
- rpId : ${JSON.stringify(kcContext.rpId)},
32
- createTimeout : ${kcContext.createTimeout}
33
- };
34
- authButton.addEventListener("click", () => {
35
- authenticateByWebAuthn({
36
- ...input,
37
- errmsg : ${JSON.stringify(msgStr("webauthn-unsupported-browser-text"))}
38
- });
39
- });
40
-
41
- initAuthenticate({
42
- ...input,
43
- errmsg : ${JSON.stringify(msgStr("passkey-unsupported-browser-text"))}
44
- });
45
- `
46
- }
47
- ]
48
- });
49
-
50
- useEffect(() => {
51
- if (isFetchingTranslations) {
52
- return;
53
- }
54
-
55
- (async () => {
56
- await waitForElementMountedOnDom({
57
- elementId: webAuthnButtonId
58
- });
59
-
60
- insertScriptTags();
61
- })();
62
- }, [isFetchingTranslations]);
63
- }
1
+ import { useInsertScriptTags } from "@keycloakify/login-ui/tools/useInsertScriptTags";
2
+ import { waitForElementMountedOnDom } from "@keycloakify/login-ui/tools/waitForElementMountedOnDom";
3
+ import { useEffect } from "react";
4
+ import { assert } from "tsafe/assert";
5
+
6
+ import { useI18n } from "../../i18n";
7
+ import { useKcContext } from "../../KcContext";
8
+
9
+ export function useScript(params: { webAuthnButtonId: string }) {
10
+ const { webAuthnButtonId } = params;
11
+
12
+ const { kcContext } = useKcContext();
13
+ assert(kcContext.pageId === "login-passkeys-conditional-authenticate.ftl");
14
+
15
+ const { msgStr, isFetchingTranslations } = useI18n();
16
+
17
+ const { insertScriptTags } = useInsertScriptTags({
18
+ effectId: "LoginRecoveryAuthnCodeConfig",
19
+ scriptTags: [
20
+ {
21
+ type: "module",
22
+ textContent: () => `
23
+ import { authenticateByWebAuthn } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/webauthnAuthenticate.js";
24
+ import { initAuthenticate } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/passkeysConditionalAuth.js";
25
+
26
+ const authButton = document.getElementById("${webAuthnButtonId}");
27
+ const input = {
28
+ isUserIdentified : ${kcContext.isUserIdentified},
29
+ challenge : ${JSON.stringify(kcContext.challenge)},
30
+ userVerification : ${JSON.stringify(kcContext.userVerification)},
31
+ rpId : ${JSON.stringify(kcContext.rpId)},
32
+ createTimeout : ${kcContext.createTimeout}
33
+ };
34
+ authButton.addEventListener("click", () => {
35
+ authenticateByWebAuthn({
36
+ ...input,
37
+ errmsg : ${JSON.stringify(msgStr("webauthn-unsupported-browser-text"))}
38
+ });
39
+ });
40
+
41
+ initAuthenticate({
42
+ ...input,
43
+ errmsg : ${JSON.stringify(msgStr("passkey-unsupported-browser-text"))}
44
+ });
45
+ `
46
+ }
47
+ ]
48
+ });
49
+
50
+ useEffect(() => {
51
+ if (isFetchingTranslations) {
52
+ return;
53
+ }
54
+
55
+ (async () => {
56
+ await waitForElementMountedOnDom({
57
+ elementId: webAuthnButtonId
58
+ });
59
+
60
+ insertScriptTags();
61
+ })();
62
+ }, [isFetchingTranslations]);
63
+ }
@@ -11,71 +11,70 @@ export default meta;
11
11
 
12
12
  type Story = StoryObj<typeof meta>;
13
13
 
14
- export const Default: Story = {
15
- render: () => <KcPageStory />
16
- };
14
+ export const Default: Story = {};
17
15
 
18
16
  export const WithPasswordError: Story = {
19
- render: () => (
20
- <KcPageStory
21
- kcContext={{
22
- realm: {
23
- resetPasswordAllowed: true
24
- },
25
- url: {
26
- loginAction: "/mock-login",
27
- loginResetCredentialsUrl: "/mock-reset-password"
28
- },
29
- messagesPerField: {
30
- existsError: (field: string) => field === "password",
31
- get: () => "Invalid password"
32
- }
33
- }}
34
- />
35
- )
17
+ args: {
18
+ kcContext: {
19
+ realm: {
20
+ resetPasswordAllowed: true
21
+ },
22
+ url: {
23
+ loginAction: "/mock-login",
24
+ loginResetCredentialsUrl: "/mock-reset-password"
25
+ },
26
+ messagesPerField: {
27
+ existsError: (field: string) => field === "password",
28
+ get: () => "Invalid password"
29
+ }
30
+ }
31
+ }
36
32
  };
37
33
 
38
34
  export const Arabic: Story = {
39
- render: () => (
40
- <KcPageStory
41
- kcContext={{
42
- locale: {
43
- currentLanguageTag: "ar",
44
- rtl: true
45
- }
46
- }}
47
- />
48
- )
35
+ args: {
36
+ kcContext: {
37
+ locale: {
38
+ currentLanguageTag: "ar",
39
+ rtl: true
40
+ }
41
+ }
42
+ }
43
+ };
44
+ export const French: Story = {
45
+ args: {
46
+ kcContext: {
47
+ locale: {
48
+ currentLanguageTag: "fr"
49
+ }
50
+ }
51
+ }
49
52
  };
50
53
 
51
54
  export const WithWebauthn: Story = {
52
- render: () => (
53
- <KcPageStory
54
- kcContext={{
55
- url: {
56
- loginAction: "/mock-login-action"
57
- },
58
- enableWebAuthnConditionalUI: true
59
- }}
60
- />
61
- )
55
+ args: {
56
+ kcContext: {
57
+ url: {
58
+ loginAction: "/mock-login-action"
59
+ },
60
+ enableWebAuthnConditionalUI: true
61
+ }
62
+ }
62
63
  };
63
64
 
64
65
  export const WithoutResetPasswordOption: Story = {
65
- render: () => (
66
- <KcPageStory
67
- kcContext={{
68
- realm: {
69
- resetPasswordAllowed: false
70
- },
71
- url: {
72
- loginAction: "/mock-login",
73
- loginResetCredentialsUrl: "/mock-reset-password"
74
- },
75
- messagesPerField: {
76
- existsError: () => false
77
- }
78
- }}
79
- />
80
- )
66
+ args: {
67
+ kcContext: {
68
+ realm: {
69
+ resetPasswordAllowed: false
70
+ },
71
+ url: {
72
+ loginAction: "/mock-login",
73
+ loginResetCredentialsUrl: "/mock-reset-password"
74
+ },
75
+ messagesPerField: {
76
+ existsError: () => false
77
+ }
78
+ }
79
+ }
81
80
  };
@@ -1,149 +1,148 @@
1
- import { Button } from "@/components/ui/button";
2
- import { Field, FieldError, FieldLabel } from "@/components/ui/field";
3
- import { Input } from "@/components/ui/input";
4
- import { Label } from '@/components/ui/label';
5
- import { PasswordWrapper } from '@/login/components/PasswordWrapper';
6
- import { useI18n } from '@/login/i18n';
7
- import { useKcContext } from '@/login/KcContext';
8
- import { useKcClsx } from '@keycloakify/login-ui/useKcClsx';
9
- import { kcSanitize } from "keycloakify/lib/kcSanitize";
10
- import { Fingerprint } from "lucide-react";
11
- import { useState } from "react";
12
- import { assert } from "tsafe/assert";
13
- import { Template } from "../../components/Template";
14
- import { useScript } from './useScript';
15
-
16
- export function Page() {
17
- const { kcContext } = useKcContext();
18
- assert(kcContext.pageId === "login-password.ftl");
19
-
20
- const { kcClsx } = useKcClsx();
21
-
22
- const { msg, msgStr } = useI18n();
23
-
24
- const [isLoginButtonDisabled, setIsLoginButtonDisabled] = useState(false);
25
-
26
- const webAuthnButtonId = "authenticateWebAuthnButton";
27
-
28
- useScript({ webAuthnButtonId });
29
-
30
- return (
31
- <Template
32
- headerNode={msg("doLogIn")}
33
- displayMessage={!kcContext.messagesPerField.existsError("password")}
34
- >
35
- <form
36
- id="kc-form-login"
37
- onSubmit={() => {
38
- setIsLoginButtonDisabled(true);
39
- return true;
40
- }}
41
- action={kcContext.url.loginAction}
42
- className="flex flex-col gap-4"
43
- method="post"
44
- >
45
- <Field>
46
- <FieldLabel htmlFor="password">{msg("password")}</FieldLabel>
47
- <PasswordWrapper
48
- passwordInputId="password"
49
- >
50
- <Input
51
- tabIndex={2}
52
- type="password"
53
- id="password"
54
- name="password"
55
- autoComplete="current-password"
56
- aria-invalid={kcContext.messagesPerField.existsError("password")}
57
- />
58
- </PasswordWrapper>
59
- {kcContext.messagesPerField.existsError("password") && (
60
- <FieldError>
61
- <span
62
- id="input-error"
63
- aria-live="polite"
64
- dangerouslySetInnerHTML={{
65
- __html: kcSanitize(
66
- kcContext.messagesPerField.getFirstError("password")
67
- )
68
- }}
69
- />
70
- </FieldError>
71
- )}
72
- </Field>
73
-
74
- <div className="flex justify-end">
75
- {kcContext.realm.resetPasswordAllowed && (
76
- <span className=" underline-offset-4 hover:underline">
77
- <a
78
- tabIndex={5}
79
- href={kcContext.url.loginResetCredentialsUrl}
80
- >
81
- <Label className="text-sm font-medium cursor-pointer">
82
- {msg("doForgotPassword")}
83
- </Label>
84
- </a>
85
- </span>
86
- )}
87
- </div>
88
-
89
- <div className="flex justify-end ">
90
- <Button
91
- disabled={isLoginButtonDisabled}
92
- className="w-full"
93
- name="login"
94
- type="submit"
95
- tabIndex={4}
96
- >
97
- {msgStr("doLogIn")}
98
- </Button>
99
- </div>
100
- </form>
101
- {kcContext.enableWebAuthnConditionalUI && (
102
- <>
103
- <form id="webauth" action={kcContext.url.loginAction} method="post">
104
- <input type="hidden" id="clientDataJSON" name="clientDataJSON" />
105
- <input
106
- type="hidden"
107
- id="authenticatorData"
108
- name="authenticatorData"
109
- />
110
- <input type="hidden" id="signature" name="signature" />
111
- <input type="hidden" id="credentialId" name="credentialId" />
112
- <input type="hidden" id="userHandle" name="userHandle" />
113
- <input type="hidden" id="error" name="error" />
114
- </form>
115
-
116
- {kcContext.authenticators !== undefined &&
117
- kcContext.authenticators.authenticators.length !== 0 && (
118
- <>
119
- <form id="authn_select" className={kcClsx("kcFormClass")}>
120
- {kcContext.authenticators.authenticators.map(
121
- (authenticator, i) => (
122
- <input
123
- key={i}
124
- type="hidden"
125
- name="authn_use_chk"
126
- readOnly
127
- value={authenticator.credentialId}
128
- />
129
- )
130
- )}
131
- </form>
132
- </>
133
- )}
134
- <br />
135
-
136
- <Button
137
- id={webAuthnButtonId}
138
- type="button"
139
- className="w-full"
140
- variant="outline"
141
- >
142
- <Fingerprint className="w-4 h-4" />
143
- {msgStr("passkey-doAuthenticate")}
144
- </Button>
145
- </>
146
- )}
147
- </Template>
148
- );
149
- }
1
+ import { Button } from "@/components/ui/button";
2
+ import { Field, FieldError, FieldLabel } from "@/components/ui/field";
3
+ import { Input } from "@/components/ui/input";
4
+ import { Label } from "@/components/ui/label";
5
+ import { PasswordWrapper } from "@/login/components/PasswordWrapper";
6
+ import { useI18n } from "@/login/i18n";
7
+ import { useKcContext } from "@/login/KcContext";
8
+ import { useKcClsx } from "@keycloakify/login-ui/useKcClsx";
9
+ import { kcSanitize } from "keycloakify/lib/kcSanitize";
10
+ import { Fingerprint } from "lucide-react";
11
+ import { useState } from "react";
12
+ import { assert } from "tsafe/assert";
13
+ import { Template } from "../../components/Template";
14
+ import { useScript } from "./useScript";
15
+
16
+ export function Page() {
17
+ const { kcContext } = useKcContext();
18
+ assert(kcContext.pageId === "login-password.ftl");
19
+
20
+ const { kcClsx } = useKcClsx();
21
+
22
+ const { msg, msgStr } = useI18n();
23
+
24
+ const [isLoginButtonDisabled, setIsLoginButtonDisabled] = useState(false);
25
+
26
+ const webAuthnButtonId = "authenticateWebAuthnButton";
27
+
28
+ useScript({ webAuthnButtonId });
29
+
30
+ return (
31
+ <Template
32
+ headerNode={msg("doLogIn")}
33
+ displayMessage={!kcContext.messagesPerField.existsError("password")}
34
+ >
35
+ <form
36
+ id="kc-form-login"
37
+ onSubmit={() => {
38
+ setIsLoginButtonDisabled(true);
39
+ return true;
40
+ }}
41
+ action={kcContext.url.loginAction}
42
+ className="flex flex-col gap-4"
43
+ method="post"
44
+ >
45
+ <Field>
46
+ <FieldLabel htmlFor="password">{msg("password")}</FieldLabel>
47
+ <PasswordWrapper passwordInputId="password">
48
+ <Input
49
+ tabIndex={2}
50
+ type="password"
51
+ id="password"
52
+ name="password"
53
+ autoComplete="current-password"
54
+ aria-invalid={kcContext.messagesPerField.existsError(
55
+ "password"
56
+ )}
57
+ />
58
+ </PasswordWrapper>
59
+ {kcContext.messagesPerField.existsError("password") && (
60
+ <FieldError>
61
+ <span
62
+ id="input-error"
63
+ aria-live="polite"
64
+ dangerouslySetInnerHTML={{
65
+ __html: kcSanitize(
66
+ kcContext.messagesPerField.getFirstError(
67
+ "password"
68
+ )
69
+ )
70
+ }}
71
+ />
72
+ </FieldError>
73
+ )}
74
+ </Field>
75
+
76
+ <div className="flex justify-end">
77
+ {kcContext.realm.resetPasswordAllowed && (
78
+ <span className=" underline-offset-4 hover:underline">
79
+ <a tabIndex={5} href={kcContext.url.loginResetCredentialsUrl}>
80
+ <Label className="text-sm font-medium cursor-pointer">
81
+ {msg("doForgotPassword")}
82
+ </Label>
83
+ </a>
84
+ </span>
85
+ )}
86
+ </div>
87
+
88
+ <div className="flex justify-end ">
89
+ <Button
90
+ disabled={isLoginButtonDisabled}
91
+ className="w-full"
92
+ name="login"
93
+ type="submit"
94
+ tabIndex={4}
95
+ >
96
+ {msgStr("doLogIn")}
97
+ </Button>
98
+ </div>
99
+ </form>
100
+ {kcContext.enableWebAuthnConditionalUI && (
101
+ <>
102
+ <form id="webauth" action={kcContext.url.loginAction} method="post">
103
+ <input type="hidden" id="clientDataJSON" name="clientDataJSON" />
104
+ <input
105
+ type="hidden"
106
+ id="authenticatorData"
107
+ name="authenticatorData"
108
+ />
109
+ <input type="hidden" id="signature" name="signature" />
110
+ <input type="hidden" id="credentialId" name="credentialId" />
111
+ <input type="hidden" id="userHandle" name="userHandle" />
112
+ <input type="hidden" id="error" name="error" />
113
+ </form>
114
+
115
+ {kcContext.authenticators !== undefined &&
116
+ kcContext.authenticators.authenticators.length !== 0 && (
117
+ <>
118
+ <form id="authn_select" className={kcClsx("kcFormClass")}>
119
+ {kcContext.authenticators.authenticators.map(
120
+ (authenticator, i) => (
121
+ <input
122
+ key={i}
123
+ type="hidden"
124
+ name="authn_use_chk"
125
+ readOnly
126
+ value={authenticator.credentialId}
127
+ />
128
+ )
129
+ )}
130
+ </form>
131
+ </>
132
+ )}
133
+ <br />
134
+
135
+ <Button
136
+ id={webAuthnButtonId}
137
+ type="button"
138
+ className="w-full"
139
+ variant="outline"
140
+ >
141
+ <Fingerprint className="w-4 h-4" />
142
+ {msgStr("passkey-doAuthenticate")}
143
+ </Button>
144
+ </>
145
+ )}
146
+ </Template>
147
+ );
148
+ }
@@ -1,3 +1,3 @@
1
- import { Page } from "./Page";
2
-
3
- export default Page;
1
+ import { Page } from "./Page";
2
+
3
+ export default Page;