|
1 | | -import { useTranslation, Trans } from "react-i18next"; |
| 1 | +import { useEffect, useState } from "react"; |
| 2 | +import DOMPurify from "dompurify"; |
| 3 | +import AdminConfigLoader from "../../util/admin-config-loader"; |
2 | 4 | import Logo from "../logo"; |
3 | 5 |
|
| 6 | +const SANITIZE_OPTIONS = { |
| 7 | + ALLOWED_TAGS: ["strong", "em", "b", "i", "br", "p", "a", "span"], |
| 8 | + ALLOWED_ATTR: ["href", "title", "target", "rel", "class"], |
| 9 | +}; |
| 10 | + |
4 | 11 | const LoginSidebar = () => { |
5 | | - const { t } = useTranslation("common", { keyPrefix: "login-sidebar" }); |
| 12 | + const [customHtml, setCustomHtml] = useState(""); |
| 13 | + |
| 14 | + useEffect(() => { |
| 15 | + AdminConfigLoader.loadConfig().then((cfg) => { |
| 16 | + const raw = cfg?.loginScreenText?.trim(); |
| 17 | + if (raw) setCustomHtml(DOMPurify.sanitize(raw, SANITIZE_OPTIONS)); |
| 18 | + }); |
| 19 | + }, []); |
6 | 20 |
|
7 | 21 | return ( |
8 | 22 | <div className="background-image-screens p-4 col-md-4"> |
9 | 23 | <Logo /> |
10 | | - <div className="card text-white bg-dark mb-3 border border-color-white"> |
11 | | - <div className="card-body"> |
12 | | - <p className="card-text" id="ad-explanation"> |
13 | | - <Trans>{t("internal-info-text")}</Trans> |
14 | | - </p> |
15 | | - <p className="card-text" id="mitid-explanation"> |
16 | | - <Trans>{t("external-info-text")}</Trans> |
17 | | - </p> |
| 24 | + {customHtml && ( |
| 25 | + <div className="card text-white bg-dark mb-3 border border-color-white"> |
| 26 | + <div className="card-body"> |
| 27 | + <div |
| 28 | + className="card-text" |
| 29 | + // eslint-disable-next-line react/no-danger |
| 30 | + dangerouslySetInnerHTML={{ __html: customHtml }} |
| 31 | + /> |
| 32 | + </div> |
18 | 33 | </div> |
19 | | - </div> |
| 34 | + )} |
20 | 35 | </div> |
21 | 36 | ); |
22 | 37 | }; |
|
0 commit comments