Skip to content

Commit c458d7e

Browse files
authored
Merge pull request #446 from os2display/feature/configurable-login-screen-text
feat: configurable login screen text
2 parents e04e49f + 34e1bae commit c458d7e

10 files changed

Lines changed: 55 additions & 17 deletions

File tree

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ ADMIN_TOUCH_BUTTON_REGIONS=false
188188
ADMIN_LOGIN_METHODS='[{"type":"username-password","enabled":true,"provider":"username-password","label":""}]'
189189
# Enable enhanced preview mode with additional features.
190190
ADMIN_ENHANCED_PREVIEW=false
191+
# Optional HTML block shown in the login sidebar.
192+
# Allowed tags: strong, em, b, i, br, p, a, span. Allowed attrs: href, title, target, rel, class.
193+
# Leave empty to hide the sidebar text card entirely.
194+
ADMIN_LOGIN_SCREEN_TEXT=
191195
###< Admin configuration ###
192196

193197
###> Client configuration ###

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
- Made the Admin login sidebar text configurable via the new `ADMIN_LOGIN_SCREEN_TEXT`
8+
env var. The value accepts a small allow-list of HTML tags (sanitized client-side
9+
with DOMPurify); when empty the sidebar card is hidden entirely. Removed the
10+
bundled Danish "medarbejder/borger MitID" copy that previously rendered by default.
11+
- Fixed login screen styling issue resulting in header not filling parent in some breakpoints.
712
- Fixed Calendar and Colibo feed configuration urls and added [] result when no locationEndpoint is set.
813
- Fixed baked-in `.env` shipping `APP_ENV=dev` in the API image; rewritten to `prod` at build time so
914
direct reads don't try to bootstrap a dev environment the prod-only dependencies can't satisfy.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ ADMIN_SHOW_SCREEN_STATUS=false
480480
ADMIN_TOUCH_BUTTON_REGIONS=false
481481
ADMIN_LOGIN_METHODS='[{"type":"username-password","enabled":true,"provider":"username-password","label":""}]'
482482
ADMIN_ENHANCED_PREVIEW=false
483+
ADMIN_LOGIN_SCREEN_TEXT=''
483484
###< Admin configuration ###
484485
```
485486

@@ -529,6 +530,16 @@ ADMIN_ENHANCED_PREVIEW=false
529530
See [Preview mode in the Client](#preview-mode-in-the-client).
530531

531532
**Default**: Disabled.
533+
- ADMIN_LOGIN_SCREEN_TEXT: Optional explanatory text rendered in the sidebar card on the Admin login page.
534+
Accepts a small allow-list of HTML tags (`strong`, `em`, `b`, `i`, `br`, `p`, `a`, `span`) and attributes
535+
(`href`, `title`, `target`, `rel`, `class`); the value is sanitized client-side with DOMPurify before being
536+
rendered. Leave empty to hide the sidebar card entirely.
537+
538+
```dotenv
539+
ADMIN_LOGIN_SCREEN_TEXT='<p>Er du <strong>medarbejder</strong> skal du benytte medarbejderlogin.</p><p>Er du <strong>borger</strong> skal du benytte MitID login.</p>'
540+
```
541+
542+
**Default**: Empty (no sidebar card shown).
532543

533544
### Client configuration
534545

assets/admin/components/navigation/login-sidebar/login-sidebar.jsx

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
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";
24
import Logo from "../logo";
35

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+
411
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+
}, []);
620

721
return (
822
<div className="background-image-screens p-4 col-md-4">
923
<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>
1833
</div>
19-
</div>
34+
)}
2035
</div>
2136
);
2237
};

assets/admin/components/user/login.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@
2222
}
2323
}
2424

25-
@media (max-width: 1075px) {
25+
@media (max-width: 1200px) {
2626
.info-box {
2727
width: 100%;
2828
padding: 2em;
2929
}
30+
31+
.col-md-4 {
32+
width: 100%;
33+
}
3034
}
3135

3236
.background-image-screens {

assets/admin/components/user/oidc-login.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ function OIDCLogin({ config }) {
7777
style={{ minWidth: "160px" }}
7878
type="button"
7979
aria-label={t("login-with-oidc-aria-label")}
80-
aria-describedby="ad-explanation"
8180
>
8281
{iconRender}
8382
{labelText}

assets/admin/components/util/admin-config-loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const AdminConfigLoader = {
3030
touchButtonRegions: false,
3131
showScreenStatus: false,
3232
enhancedPreview: false,
33+
loginScreenText: "",
3334
loginMethods: [
3435
{
3536
type: "username-password",

assets/admin/translations/da/common.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
"load-theme-error": "Der skete en fejl da temaet med følgende id: {{id}} skulle hentes:"
2121
}
2222
},
23-
"login-sidebar": {
24-
"internal-info-text": "Er du <strong>medarbejder</strong> skal du benytte medarbejderlogin.",
25-
"external-info-text": "Er du <strong>borger</strong> skal du benytte MitID login."
26-
},
2723
"slides-list": {
2824
"columns": {
2925
"name": "Titel",

config/services.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ services:
7171
$showScreenStatus: '%env(bool:ADMIN_SHOW_SCREEN_STATUS)%'
7272
$loginMethods: '%env(json:ADMIN_LOGIN_METHODS)%'
7373
$enhancedPreview: '%env(bool:ADMIN_ENHANCED_PREVIEW)%'
74+
$loginScreenText: '%env(string:ADMIN_LOGIN_SCREEN_TEXT)%'
7475

7576
App\Controller\Client\ClientConfigController:
7677
arguments:

src/Controller/Admin/AdminConfigController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct(
1818
private readonly bool $showScreenStatus,
1919
private readonly array $loginMethods,
2020
private readonly bool $enhancedPreview,
21+
private readonly string $loginScreenText,
2122
) {}
2223

2324
public function __invoke(): Response
@@ -28,6 +29,7 @@ public function __invoke(): Response
2829
'showScreenStatus' => $this->showScreenStatus,
2930
'loginMethods' => $this->loginMethods,
3031
'enhancedPreview' => $this->enhancedPreview,
32+
'loginScreenText' => $this->loginScreenText,
3133
]);
3234
}
3335
}

0 commit comments

Comments
 (0)