diff options
Diffstat (limited to 'overview/public/script.js')
-rw-r--r-- | overview/public/script.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/overview/public/script.js b/overview/public/script.js new file mode 100644 index 0000000..be058b7 --- /dev/null +++ b/overview/public/script.js @@ -0,0 +1,22 @@ +fetch("/auth/api/status").then(response => response.json()).then(response => { + console.log(response); + const first = document.querySelectorAll("a")[0]; + const second = document.querySelectorAll("a")[1]; + const third = document.querySelectorAll("a")[2]; + + if (!response.admin) + third.style.display = "none"; + + if (response.loggedIn) { + first.href = "/auth/change.html"; + first.innerText = "Passwort ändern"; + second.href = "/auth/api/logout"; + second.innerText = "Logout"; + if (response.admin) { + third.href = "/admin"; + third.innerText = "Administration"; + } + } else { + document.querySelectorAll("div.pure-menu")[0].style.display = "none"; + } +}); |