From b32ffdbb611dc401a8b4344d7e7c886a13523dff Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 4 Oct 2026 19:54:30 -0600 Subject: [PATCH] fix(security): remove daily limit edit pencil from student view, hide parent button for students, and enforce read-only student permissions --- public/index.html | 5 ++--- public/js/app.js | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/public/index.html b/public/index.html index 6114924..52c87c8 100644 --- a/public/index.html +++ b/public/index.html @@ -301,12 +301,11 @@ - -
+ +
Límite diario fijado: ₡0 - ✏️ Cambiar
Disponible hoy: ₡0 diff --git a/public/js/app.js b/public/js/app.js index 656e914..8261a23 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -173,13 +173,20 @@ async function applyUserRoleSession() { if (viewAdmin) viewAdmin.style.display = 'none'; if (appContainer) appContainer.style.display = 'block'; + // Mostrar botón de acceso al portal de padres + const btnPadres = document.getElementById('btnModePadres'); + if (btnPadres) btnPadres.style.display = 'inline-block'; + await loadInitialData(); setupParentPortalChildren(); toggleParentPanel(true); } else { - // Estudiante + // Estudiante: SEGURIDAD ESTRICTA - Ocultar botón de padres if (viewAdmin) viewAdmin.style.display = 'none'; if (appContainer) appContainer.style.display = 'block'; + + const btnPadres = document.getElementById('btnModePadres'); + if (btnPadres) btnPadres.style.display = 'none'; await loadInitialData(); if (currentUser.estudiante) { @@ -600,11 +607,22 @@ function closeQrModal(e) { // ========================================== function toggleParentPanel(show, e) { + // SEGURIDAD: Un estudiante no tiene acceso al portal de padres + if (currentUser && currentUser.rol === 'estudiante') { + const modalPadres = document.getElementById('modalPadres'); + if (modalPadres) modalPadres.style.display = 'none'; + return; + } if (e && e.target !== e.currentTarget) return; - document.getElementById('modalPadres').style.display = show ? 'flex' : 'none'; + const modalPadres = document.getElementById('modalPadres'); + if (modalPadres) modalPadres.style.display = show ? 'flex' : 'none'; } function openDailyLimitEditor() { + // SEGURIDAD: Los estudiantes no pueden modificar su límite diario + if (!currentUser || currentUser.rol === 'estudiante') { + return; + } toggleParentPanel(true); setTimeout(() => { const input = document.getElementById('inputCustomDailyLimit');