fix issues related to school year
Tests / PHPUnit (push) Failing after 34s

This commit is contained in:
root
2026-07-31 18:52:25 -04:00
parent 8d7ee3b9fc
commit 09ea144bb2
23 changed files with 537 additions and 218 deletions
+42 -2
View File
@@ -2,8 +2,8 @@ class SessionTimeoutManager {
constructor() {
this.config = {
timeout: 1800, // 30 minutes
warning_time: 300, // 5 minutes before timeout
check_interval: 60000, // 1 minute
warning_time: 30, // final 30 seconds before timeout
check_interval: 5000, // 5 seconds
logout_url: '/logout',
keep_alive_url: '/session/ping-activity',
check_url: '/session/check-timeout'
@@ -140,10 +140,14 @@ class SessionTimeoutManager {
} else {
this.updateWarning(data.time_remaining);
}
this.scheduleLogout(data.time_remaining);
this.startCountdown(data.time_remaining);
}
handleSessionActive(data) {
this.clearWarning();
clearTimeout(this.timers.logoutTimer);
this.timers.logoutTimer = null;
}
showWarning(timeRemaining) {
@@ -160,6 +164,33 @@ class SessionTimeoutManager {
}
}
scheduleLogout(timeRemaining) {
clearTimeout(this.timers.logoutTimer);
const delay = Math.max(0, Number(timeRemaining) || 0) * 1000;
this.timers.logoutTimer = setTimeout(() => {
this.handleSessionExpired({
redirect: this.config.logout_url,
message: 'Your session has expired due to inactivity. Please log in again.'
});
}, delay);
}
startCountdown(timeRemaining) {
clearInterval(this.timers.warningTimer);
let secondsRemaining = Math.max(0, Number(timeRemaining) || 0);
this.updateWarning(secondsRemaining);
this.timers.warningTimer = setInterval(() => {
secondsRemaining = Math.max(0, secondsRemaining - 1);
this.updateWarning(secondsRemaining);
if (secondsRemaining <= 0) {
clearInterval(this.timers.warningTimer);
this.timers.warningTimer = null;
}
}, 1000);
}
createWarningModal(timeRemaining) {
this.hideWarning();
@@ -185,6 +216,9 @@ class SessionTimeoutManager {
<p style="font-size: 1.1em; margin-bottom: 20px;">
Your session will expire in <span class="countdown" style="font-weight: bold; color: #e74c3c;">${timeRemaining}</span> seconds due to inactivity.
</p>
<p style="font-size: 1em; margin-bottom: 0;">
Click Continue Session if you want to keep using this session.
</p>
<div style="margin-top: 25px;">
<button onclick="sessionTimeout.continueSession()"
style="background: #27ae60; color: white; border: none; padding: 12px 24px;
@@ -215,6 +249,10 @@ class SessionTimeoutManager {
clearWarning() {
this.hideWarning();
clearTimeout(this.timers.logoutTimer);
this.timers.logoutTimer = null;
clearInterval(this.timers.warningTimer);
this.timers.warningTimer = null;
}
continueSession() {
@@ -228,6 +266,8 @@ class SessionTimeoutManager {
destroy() {
clearInterval(this.timers.checkTimer);
clearTimeout(this.timers.logoutTimer);
clearInterval(this.timers.warningTimer);
this.hideWarning();
}
}