major RBAC imrpovements + fix thumbnails

This commit is contained in:
KingKDot
2026-07-21 13:18:30 -05:00
parent 9b885ad2ef
commit d602de396e
23 changed files with 599 additions and 213 deletions
+15 -11
View File
@@ -68,6 +68,8 @@ async function checkAuth() {
}
const data = await res.json();
const permissions = Array.isArray(data.permissions) ? data.permissions : [];
const hasPermission = (permission) => permissions.includes(permission);
document.getElementById("username-display").textContent = data.username;
const roleBadge = document.getElementById("role-badge");
@@ -105,25 +107,27 @@ async function checkAuth() {
);
}
if (data.role === "admin") {
if (hasPermission("audit:view")) {
document.getElementById("metrics-link")?.classList.remove("hidden");
}
if (hasPermission("scripts:manage")) {
document.getElementById("scripts-link")?.classList.remove("hidden");
}
if (hasPermission("clients:build") || data.canBuild) {
document.getElementById("build-link")?.classList.remove("hidden");
}
if (hasPermission("deploys:manage")) {
document.getElementById("deploy-link")?.classList.remove("hidden");
}
if (hasPermission("users:manage")) {
document.getElementById("users-link")?.classList.remove("hidden");
}
if (hasPermission("plugins:manage")) {
document.getElementById("plugins-link")?.classList.remove("hidden");
} else if (data.role === "operator") {
document.getElementById("metrics-link")?.classList.remove("hidden");
document.getElementById("scripts-link")?.classList.remove("hidden");
document.getElementById("build-link")?.classList.remove("hidden");
}
if (data.canBuild) {
document.getElementById("build-link")?.classList.remove("hidden");
}
if (data.role === "viewer") {
alert("Access denied. Operator or Admin role required.");
if (!hasPermission("scripts:manage")) {
alert("Access denied. Missing scripts:manage permission.");
window.location.href = "/";
}
} catch (err) {