Goal-Calibration/public/js/nav.js
2026-05-03 19:24:10 +03:00

18 lines
451 B
JavaScript

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;
}
});