Files
nextcloud/php/public/notifications.js
T
Pablo Zmdl 93cf3d3931 Two factor authentication for both login variants
This adds optional two factor authentication based on shared
TOTP-secrets to both login variants (password and AIO token
authentication).

The 2FA can be enabled as soon as the containers are running in a
section below the backup configuration. As long as it is not enabled,
the AIO UI shows a warning at the top, and inside the Nextcloud a
notification is shown to all Nextcloud admins, strongly recommending to
enable it. The Nextcloud admin notification is sent via the
mastercontainer's `cron.sh`, thus will be renewed whenever it is
dismissed.

In order to show the notices, this PR includes a notification system for
the AIO UI, providing two variants: notices, and warnings. Notices have
a green background and border and vanish after 5 seconds. Warnings have
a orange-leaning yellow background and border and don't vanish (and
can't be dismissed manually, neither).

Another visual improvement is highlighted section headlines: If the URL
hash matches an `h2` element's ID, the `h2` is highlighted and if the
`h2` is followed by a `detail` element, that `detail` is opened. If
effect, browsing to `#two-factor-auth` jumps to the section, which is
highlighted and opened already (as shown in the second screenshot
below).

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
AI-assistant: Claude Opus 4.8
2026-08-20 16:33:29 +02:00

22 lines
627 B
JavaScript

"use strict";
// Auto-dismisses temporary notifications (see NotificationService / notifications.twig)
// a few seconds after the page loads. Permanent notifications are left untouched.
(function () {
const TIMEOUT_MS = 5000;
function dismissTemporaryNotifications() {
document.querySelectorAll(".notification--temporary").forEach(function (el) {
setTimeout(function () {
el.remove();
}, TIMEOUT_MS);
});
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", dismissTemporaryNotifications);
} else {
dismissTemporaryNotifications();
}
})();