Fix redirect loop: hapus auto-redirect di index.php, hanya redirect setelah login berhasil

This commit is contained in:
mwpn
2025-12-18 11:41:47 +07:00
parent ef51cf96a2
commit da151681e1
4 changed files with 7 additions and 43 deletions

View File

@@ -69,27 +69,8 @@
} from './dashboard/js/auth.js';
window.Auth = Auth;
// Jika sudah login, langsung arahkan ke dashboard
// Cek dulu apakah kita sudah di dashboard untuk menghindari redirect loop
(function() {
// Cek apakah ini benar-benar halaman index.php (bukan dashboard)
const currentPath = window.location.pathname;
const isIndexPage = currentPath.endsWith('index.php') || currentPath.endsWith('/') || currentPath === '/';
const isDashboardPage = currentPath.includes('dashboard.html') || currentPath.includes('event.html') || currentPath.includes('settings.html');
// Hanya redirect jika:
// 1. User sudah authenticated
// 2. Kita di index page (bukan dashboard)
// 3. Belum pernah redirect (cek sessionStorage)
if (Auth.isAuthenticated() && isIndexPage && !isDashboardPage) {
const redirectKey = 'auth_redirect_done';
if (!sessionStorage.getItem(redirectKey)) {
sessionStorage.setItem(redirectKey, '1');
window.location.href = 'dashboard/dashboard.html';
return;
}
}
})();
// Hapus auto-redirect untuk mencegah redirect loop
// Biarkan user login dulu, redirect hanya setelah login berhasil
document.getElementById('loginForm').addEventListener('submit', async (e) => {
e.preventDefault();