From fa1ebff600ba21aa07e1257b6c20e89e2760da38 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 4 Jan 2026 09:26:26 +0000 Subject: [PATCH] Edit login.php via Editor --- login.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/login.php b/login.php index 114418b..89577d7 100644 --- a/login.php +++ b/login.php @@ -1,9 +1,11 @@ @@ -60,10 +62,7 @@ document.getElementById('login-form').addEventListener('submit', async function( const btnText = document.getElementById('btn-text'); const btnSpinner = document.getElementById('btn-spinner'); - // Hide error message errorDiv.style.display = 'none'; - - // Disable button and show spinner submitBtn.disabled = true; btnText.style.display = 'none'; btnSpinner.style.display = 'inline-block'; @@ -74,20 +73,20 @@ document.getElementById('login-form').addEventListener('submit', async function( headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ email, password }) + body: JSON.stringify({ email, password }), + credentials: 'same-origin' // Important for sessions }); const result = await response.json(); if (response.ok && result.success) { - // Successful login - window.location.href = 'index.php'; + // Add a small delay to ensure session is written + setTimeout(() => { + window.location.href = result.redirect || 'index.php'; + }, 100); } else { - // Login failed errorDiv.textContent = result.message || 'Invalid email or password.'; errorDiv.style.display = 'block'; - - // Re-enable button submitBtn.disabled = false; btnText.style.display = 'inline'; btnSpinner.style.display = 'none'; @@ -96,8 +95,6 @@ document.getElementById('login-form').addEventListener('submit', async function( console.error('Login error:', error); errorDiv.textContent = 'Failed to connect to the server. Please try again.'; errorDiv.style.display = 'block'; - - // Re-enable button submitBtn.disabled = false; btnText.style.display = 'inline'; btnSpinner.style.display = 'none';