fix(session): corregir persistencia de sesion en F5 y visibilidad de dashboard de padres
This commit is contained in:
@@ -1952,6 +1952,7 @@
|
|||||||
<span>Guardar Nuevas Credenciales</span>
|
<span>Guardar Nuevas Credenciales</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- SUBVISTA: DASHBOARD EJECUTIVO FAMILIAR -->
|
<!-- SUBVISTA: DASHBOARD EJECUTIVO FAMILIAR -->
|
||||||
<div id="parentSubViewDashboard" class="parent-subview" style="display: none;">
|
<div id="parentSubViewDashboard" class="parent-subview" style="display: none;">
|
||||||
|
|||||||
+30
-2
@@ -68,7 +68,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
|
|
||||||
// Registrar Service Worker para PWA
|
// Registrar Service Worker para PWA
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.register('/sw.js?v=13.1').then(reg => {
|
navigator.serviceWorker.register('/sw.js?v=15.0').then(reg => {
|
||||||
reg.update().catch(() => {});
|
reg.update().catch(() => {});
|
||||||
if ('Notification' in window && Notification.permission === 'granted') {
|
if ('Notification' in window && Notification.permission === 'granted') {
|
||||||
subscribeDeviceToWebPush().catch(() => {});
|
subscribeDeviceToWebPush().catch(() => {});
|
||||||
@@ -84,6 +84,12 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
localStorage.removeItem('recreopay_token');
|
localStorage.removeItem('recreopay_token');
|
||||||
localStorage.removeItem('recreopay_user');
|
localStorage.removeItem('recreopay_user');
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
|
// Limpiar ?logout=true de la URL para que no persista en el navegador y no vuelva a cerrar sesión en F5
|
||||||
|
try {
|
||||||
|
if (window.history && window.history.replaceState) {
|
||||||
|
window.history.replaceState({}, document.title, window.location.pathname);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verificar si hay sesión activa guardada
|
// Verificar si hay sesión activa guardada
|
||||||
@@ -100,7 +106,11 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
// Mostrar pantalla de Login limpia (NO auto-login)
|
// Mostrar pantalla de Login limpia (NO auto-login)
|
||||||
showLoginView();
|
showLoginView();
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
await applyUserRoleSession();
|
await applyUserRoleSession();
|
||||||
|
} catch (errRole) {
|
||||||
|
console.error('Error aplicando rol de usuario en sesión:', errRole);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initStudentSSE();
|
initStudentSSE();
|
||||||
@@ -416,6 +426,13 @@ async function handleLoginSubmit(event) {
|
|||||||
localStorage.setItem('sibopay_user', JSON.stringify(currentUser));
|
localStorage.setItem('sibopay_user', JSON.stringify(currentUser));
|
||||||
localStorage.setItem('recreopay_user', JSON.stringify(currentUser));
|
localStorage.setItem('recreopay_user', JSON.stringify(currentUser));
|
||||||
|
|
||||||
|
// Limpiar preventivamente cualquier parámetro residual de logout en la URL
|
||||||
|
try {
|
||||||
|
if (window.history && window.history.replaceState) {
|
||||||
|
window.history.replaceState({}, document.title, window.location.pathname);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
await applyUserRoleSession();
|
await applyUserRoleSession();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -618,6 +635,11 @@ function logout(skipConfirm = false) {
|
|||||||
currentStudent = null;
|
currentStudent = null;
|
||||||
currentParentChild = null;
|
currentParentChild = null;
|
||||||
adminSelectedStudent = null;
|
adminSelectedStudent = null;
|
||||||
|
try {
|
||||||
|
if (window.history && window.history.replaceState) {
|
||||||
|
window.history.replaceState({}, document.title, window.location.pathname);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
showLoginView();
|
showLoginView();
|
||||||
if (window.sounds) window.sounds.playTap();
|
if (window.sounds) window.sounds.playTap();
|
||||||
}
|
}
|
||||||
@@ -3060,6 +3082,11 @@ async function cargarDashboardPadres() {
|
|||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
const resumen = data.resumen || {};
|
const resumen = data.resumen || {};
|
||||||
|
|
||||||
|
if (data.hijos && data.hijos.length > 0 && (!currentUser.hijos || currentUser.hijos.length === 0)) {
|
||||||
|
currentUser.hijos = data.hijos;
|
||||||
|
poblarSelectorHijosDashboardPadres();
|
||||||
|
}
|
||||||
|
|
||||||
// 1. KPI Saldo
|
// 1. KPI Saldo
|
||||||
const elSaldo = document.getElementById('parentDashKpiSaldo');
|
const elSaldo = document.getElementById('parentDashKpiSaldo');
|
||||||
if (elSaldo) elSaldo.textContent = `₡${(resumen.saldo_disponible || 0).toLocaleString('es-CR')}`;
|
if (elSaldo) elSaldo.textContent = `₡${(resumen.saldo_disponible || 0).toLocaleString('es-CR')}`;
|
||||||
@@ -3206,7 +3233,8 @@ function closeParentSubView(shouldScroll = true) {
|
|||||||
'parentSubViewAlergias',
|
'parentSubViewAlergias',
|
||||||
'parentSubViewLimites',
|
'parentSubViewLimites',
|
||||||
'parentSubViewHistorial',
|
'parentSubViewHistorial',
|
||||||
'parentSubViewCredenciales'
|
'parentSubViewCredenciales',
|
||||||
|
'parentSubViewDashboard'
|
||||||
];
|
];
|
||||||
subViews.forEach(id => {
|
subViews.forEach(id => {
|
||||||
const el = document.getElementById(id);
|
const el = document.getElementById(id);
|
||||||
|
|||||||
+1
-1
@@ -2440,7 +2440,7 @@ function posLogout() {
|
|||||||
localStorage.removeItem('recreopay_user');
|
localStorage.removeItem('recreopay_user');
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
window.location.href = '/index.html?logout=true';
|
window.location.href = '/index.html';
|
||||||
}
|
}
|
||||||
window.posLogout = posLogout;
|
window.posLogout = posLogout;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@
|
|||||||
localStorage.removeItem('recreopay_user');
|
localStorage.removeItem('recreopay_user');
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
window.location.href = '/index.html?logout=true';
|
window.location.href = '/index.html';
|
||||||
}
|
}
|
||||||
window.posLogout = posLogout;
|
window.posLogout = posLogout;
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
// SiboPay PWA Service Worker v14.0 - Dashboard Ejecutivo de Padres
|
// SiboPay PWA Service Worker v15.0 - Dashboard Ejecutivo de Padres & Persistencia Sesión F5
|
||||||
const CACHE_NAME = 'sibopay-v14.0';
|
const CACHE_NAME = 'sibopay-v15.0';
|
||||||
const STATIC_ASSETS = [
|
const STATIC_ASSETS = [
|
||||||
'/',
|
'/',
|
||||||
'/index.html',
|
'/index.html',
|
||||||
|
|||||||
Reference in New Issue
Block a user