Fix redirect loop: hapus auto-redirect di index.php, hanya redirect setelah login berhasil
This commit is contained in:
@@ -73,23 +73,11 @@ async function handleLoginSubmit(event) {
|
||||
}
|
||||
|
||||
// Attach events on login page only
|
||||
// Hapus auto-redirect untuk mencegah redirect loop
|
||||
// Redirect hanya setelah login berhasil (di handleLoginSubmit)
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const form = document.getElementById('login-form');
|
||||
if (form) {
|
||||
// Cek apakah sudah authenticated dan belum di dashboard untuk menghindari redirect loop
|
||||
// Hanya redirect jika benar-benar di login page (bukan dashboard)
|
||||
const currentPath = window.location.pathname;
|
||||
const isLoginPage = currentPath.includes('index.php') || (currentPath.endsWith('/') && !currentPath.includes('dashboard'));
|
||||
const isDashboardPage = currentPath.includes('dashboard.html') || currentPath.includes('event.html') || currentPath.includes('settings.html');
|
||||
|
||||
if (Auth.isAuthenticated() && isLoginPage && !isDashboardPage) {
|
||||
const redirectKey = 'auth_redirect_done';
|
||||
if (!sessionStorage.getItem(redirectKey)) {
|
||||
sessionStorage.setItem(redirectKey, '1');
|
||||
window.location.href = 'dashboard.html';
|
||||
return;
|
||||
}
|
||||
}
|
||||
form.addEventListener('submit', handleLoginSubmit);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user