Fix redirect loop: tambah sessionStorage guard dan path check yang lebih ketat
This commit is contained in:
@@ -695,9 +695,19 @@ function initCharts() {
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
// Require auth
|
||||
if (!Auth.isAuthenticated()) {
|
||||
window.location.href = '../index.php';
|
||||
// Cek apakah sudah di login page untuk mencegah redirect loop
|
||||
const currentPath = window.location.pathname;
|
||||
const isLoginPage = currentPath.includes('index.php');
|
||||
if (!isLoginPage) {
|
||||
// Clear redirect flag jika logout
|
||||
sessionStorage.removeItem('auth_redirect_done');
|
||||
window.location.href = '../index.php';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear redirect flag saat sudah di dashboard
|
||||
sessionStorage.removeItem('auth_redirect_done');
|
||||
|
||||
// Set default date ke hari ini (jangan auto-detect ke tanggal lama)
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
|
||||
Reference in New Issue
Block a user