-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): customise IdpProfile page, to add same acceptance button …
…used on main registration form (#2294) * add page * update
- Loading branch information
1 parent
de4cb8f
commit c10dde4
Showing
4 changed files
with
103 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
keycloak/keycloakify/src/login/pages/AcceptanceOfTerms.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
|
||
interface AcceptanceOfTermsProps { | ||
termsMessage: string; | ||
onAgreeChange: (agreed: boolean) => void; | ||
} | ||
|
||
const AcceptanceOfTerms: React.FC<AcceptanceOfTermsProps> = ({ termsMessage, onAgreeChange }) => { | ||
return ( | ||
<div style={{ marginLeft: "1.5em", marginRight: "1.5em" }}> | ||
<div dangerouslySetInnerHTML={{ __html: termsMessage }}></div> | ||
<div> | ||
<label> | ||
<input | ||
type="checkbox" | ||
id="terms" | ||
name="terms" | ||
onChange={(e) => onAgreeChange(e.target.checked)} | ||
/> I agree | ||
</label> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AcceptanceOfTerms; |
59 changes: 59 additions & 0 deletions
59
keycloak/keycloakify/src/login/pages/IdpReviewUserProfile.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { useState } from "react"; | ||
import { clsx } from "keycloakify/tools/clsx"; | ||
import { UserProfileFormFields } from "keycloakify/login/pages/shared/UserProfileFormFields"; | ||
import type { PageProps } from "keycloakify/login/pages/PageProps"; | ||
import { useGetClassName } from "keycloakify/login/lib/useGetClassName"; | ||
import type { KcContext } from "../kcContext"; | ||
import type { I18n } from "../i18n"; | ||
import AcceptanceOfTerms from "./AcceptanceOfTerms"; | ||
|
||
export default function IdpReviewUserProfile(props: PageProps<Extract<KcContext, { pageId: "idp-review-user-profile.ftl" }>, I18n>) { | ||
const { kcContext, i18n, doUseDefaultCss, Template, classes } = props; | ||
|
||
const { getClassName } = useGetClassName({ | ||
doUseDefaultCss, | ||
classes | ||
}); | ||
|
||
const { msg, msgStr } = i18n; | ||
|
||
const { url } = kcContext; | ||
|
||
const [isFormSubmittable, setIsFormSubmittable] = useState(false); | ||
const [didAgree, setDidAgree] = useState(false); | ||
|
||
return ( | ||
<Template {...{ kcContext, i18n, doUseDefaultCss, classes }} headerNode={msg("loginIdpReviewProfileTitle")}> | ||
<form id="kc-idp-review-profile-form" className={getClassName("kcFormClass")} action={url.loginAction} method="post"> | ||
<UserProfileFormFields | ||
kcContext={kcContext} | ||
onIsFormSubmittableValueChange={setIsFormSubmittable} | ||
i18n={i18n} | ||
getClassName={getClassName} | ||
/> | ||
<div className={getClassName("kcFormGroupClass")}> | ||
<AcceptanceOfTerms | ||
termsMessage={kcContext.properties.REGISTRATION_TERMS_MESSAGE || ''} | ||
onAgreeChange={setDidAgree} | ||
/> | ||
<div id="kc-form-options" className={getClassName("kcFormOptionsClass")}> | ||
<div className={getClassName("kcFormOptionsWrapperClass")} /> | ||
</div> | ||
<div id="kc-form-buttons" className={getClassName("kcFormButtonsClass")}> | ||
<input | ||
className={clsx( | ||
getClassName("kcButtonClass"), | ||
getClassName("kcButtonPrimaryClass"), | ||
getClassName("kcButtonBlockClass"), | ||
getClassName("kcButtonLargeClass") | ||
)} | ||
type="submit" | ||
value={msgStr("doSubmit")} | ||
disabled={!isFormSubmittable || !didAgree} | ||
/> | ||
</div> | ||
</div> | ||
</form> | ||
</Template> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters