diff options
Diffstat (limited to 'overview')
-rw-r--r-- | overview/public/index.html | 7 | ||||
-rw-r--r-- | overview/public/script.js | 22 |
2 files changed, 27 insertions, 2 deletions
diff --git a/overview/public/index.html b/overview/public/index.html index c97b83f..f9bc2d8 100644 --- a/overview/public/index.html +++ b/overview/public/index.html @@ -15,8 +15,9 @@ </head> <body> <div class="pure-menu pure-menu-horizontal"> - <a href="/auth/change.html" class="pure-menu-item pure-menu-link">Passwort ändern</a> - <a href="/auth/api/logout" class="pure-menu-item pure-menu-link">Logout</a> + <a href="" class="pure-menu-item pure-menu-link"></a> + <a href="" class="pure-menu-item pure-menu-link"></a> + <a href="" class="pure-menu-item pure-menu-link"></a> </div> <div class="card"> <h2>Hallo, liebe RBS-Schüler*innen!</h2> @@ -45,5 +46,7 @@ <li><a href="https://github.com/marvinborner/Abizeugs/">Öffentlicher Source-Code</a></li> </ul> </div> + + <script src="script.js"></script> </body> </html> 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"; + } +}); |