From 56c3878d2ebd4295d7953613675be8b03b913d99 Mon Sep 17 00:00:00 2001
From: Orazio <22700499+orazioedoardo@users.noreply.github.com>
Date: Sun, 11 Aug 2024 09:38:20 +0200
Subject: [PATCH] Replace inline onclick with addEventListener inside .js file
to be compatible with CSP
Signed-off-by: Orazio <22700499+orazioedoardo@users.noreply.github.com>
---
scripts/pi-hole/js/logout.js | 6 ++++++
scripts/pi-hole/lua/header_authenticated.lp | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 scripts/pi-hole/js/logout.js
diff --git a/scripts/pi-hole/js/logout.js b/scripts/pi-hole/js/logout.js
new file mode 100644
index 000000000..cffef77a2
--- /dev/null
+++ b/scripts/pi-hole/js/logout.js
@@ -0,0 +1,6 @@
+document.addEventListener("DOMContentLoaded", () => {
+ logout_button = document.getElementById("logout-button");
+ logout_button.addEventListener("click", () => {
+ utils.doLogout();
+ });
+});
diff --git a/scripts/pi-hole/lua/header_authenticated.lp b/scripts/pi-hole/lua/header_authenticated.lp
index f4a297f41..d27b80a27 100644
--- a/scripts/pi-hole/lua/header_authenticated.lp
+++ b/scripts/pi-hole/lua/header_authenticated.lp
@@ -9,6 +9,7 @@
]]--
mg.include('header.lp','r')
?>
+
@@ -85,7 +86,7 @@ mg.include('header.lp','r')
GitHub
Pi-hole Releases
if pihole.needLogin() then ?>
- Log out
+ Log out
end ?>