add admin nav link

This commit is contained in:
Yisroel Baum 2026-05-03 19:18:44 +03:00
parent a62b8763f0
commit a6f7abe2fd
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
5 changed files with 30 additions and 0 deletions

18
public/js/nav.js Normal file
View file

@ -0,0 +1,18 @@
document.addEventListener('DOMContentLoaded', async () => {
const adminLink = document.getElementById('admin-link');
if (adminLink === null) {
return;
}
const response = await fetch('/api/auth/me', {
credentials: 'same-origin',
});
if (!response.ok) {
return;
}
const body = await response.json();
if (body.user && body.user.isAdmin === true) {
adminLink.hidden = false;
}
});