Links
✒

Terms and conditions

Many organizations have a requirement that when a new user logs in for the first time, they need to agree to the terms and conditions of the website.
First you need to enable the required action on the Keycloak server admin console:
Then you load your own therms in Markdown format like this:
import type { KcContext } from "./kcContext";
import KcAppBase, { defaultKcProps, useDownloadTerms } from "keycloakify";
import tos_en_url from "./tos_en.md";
import tos_fr_url from "./tos_fr.md";
​
export type Props = {
kcContext: KcContext;
};
​
export default function KcApp(props: Props) {
const { kcContext } = props;
​
useDownloadTerms({
kcContext,
"downloadTermMarkdown": async ({ currentLanguageTag }) => {
const markdownString = await fetch((() => {
switch (currentLanguageTag) {
case "fr": return tos_fr_url;
default: return tos_en_url;
}
})()).then(response => response.text());
​
return markdownString;
}
});
​
return (
<KcAppBase
kcContext={kcContext}
{...defaultKcProps}
/>
);
}