fix(security): remove daily limit edit pencil from student view, hide parent button for students, and enforce read-only student permissions

This commit is contained in:
unknown
2026-10-04 19:54:30 -06:00
parent c2f09370bf
commit b32ffdbb61
2 changed files with 22 additions and 5 deletions
+2 -3
View File
@@ -301,12 +301,11 @@
</div> </div>
</section> </section>
<!-- BANNER DE LÍMITE DIARIO Y SALUD (TOCABLE PARA EDITAR) --> <!-- BANNER DE LÍMITE DIARIO Y DISPONIBILIDAD (SÓLO LECTURA INFORMATIVA PARA EL ESTUDIANTE) -->
<div class="daily-limit-badge" id="dailyLimitBadge" onclick="openDailyLimitEditor()" style="cursor: pointer;" title="Toca aquí para escribir o ajustar el límite diario"> <div class="daily-limit-badge" id="dailyLimitBadge" style="cursor: default;" title="Límite diario establecido por tus padres">
<div> <div>
<span>Límite diario fijado: </span> <span>Límite diario fijado: </span>
<strong id="dailyLimitText">₡0</strong> <strong id="dailyLimitText">₡0</strong>
<span style="font-size: 0.72rem; color: #0284c7; background: #e0f2fe; padding: 2px 7px; border-radius: 6px; margin-left: 6px; font-weight: 800;">✏️ Cambiar</span>
</div> </div>
<div style="font-size: 0.76rem; color: var(--text-muted);" id="dailyAvailableText"> <div style="font-size: 0.76rem; color: var(--text-muted);" id="dailyAvailableText">
Disponible hoy: ₡0 Disponible hoy: ₡0
+20 -2
View File
@@ -173,14 +173,21 @@ async function applyUserRoleSession() {
if (viewAdmin) viewAdmin.style.display = 'none'; if (viewAdmin) viewAdmin.style.display = 'none';
if (appContainer) appContainer.style.display = 'block'; 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(); await loadInitialData();
setupParentPortalChildren(); setupParentPortalChildren();
toggleParentPanel(true); toggleParentPanel(true);
} else { } else {
// Estudiante // Estudiante: SEGURIDAD ESTRICTA - Ocultar botón de padres
if (viewAdmin) viewAdmin.style.display = 'none'; if (viewAdmin) viewAdmin.style.display = 'none';
if (appContainer) appContainer.style.display = 'block'; if (appContainer) appContainer.style.display = 'block';
const btnPadres = document.getElementById('btnModePadres');
if (btnPadres) btnPadres.style.display = 'none';
await loadInitialData(); await loadInitialData();
if (currentUser.estudiante) { if (currentUser.estudiante) {
await selectStudent(currentUser.estudiante.id); await selectStudent(currentUser.estudiante.id);
@@ -600,11 +607,22 @@ function closeQrModal(e) {
// ========================================== // ==========================================
function toggleParentPanel(show, 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; 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() { function openDailyLimitEditor() {
// SEGURIDAD: Los estudiantes no pueden modificar su límite diario
if (!currentUser || currentUser.rol === 'estudiante') {
return;
}
toggleParentPanel(true); toggleParentPanel(true);
setTimeout(() => { setTimeout(() => {
const input = document.getElementById('inputCustomDailyLimit'); const input = document.getElementById('inputCustomDailyLimit');