add logging to main auth

This commit is contained in:
chris 2025-08-10 09:25:18 -04:00
parent 2072aa30ef
commit 6cb764faf7

View File

@ -23,12 +23,23 @@ let authToken = null;
// --- EVENT HANDLERS (The "Logic") ---
async function handleAuthSubmit(e) {
console.log("1. Form submitted, handleAuthSubmit function started."); // Checkpoint 1
e.preventDefault();
const username = e.target.elements.username.value;
const password = e.target.elements.password.value;
console.log(`2. Attempting to log in user: ${username}`); // Checkpoint 2
const res = await apiCall('/login', 'POST', { username, password });
if (res.success) {
console.log("3. Received response from apiCall:", res); // Checkpoint 3
if (res && res.success) {
console.log("4. Login was successful, calling initializeApp()."); // Checkpoint 4
initializeApp();
} else {
console.error("5. Login failed. Server response:", res); // Checkpoint 5
// We can add a user-facing error message here
showMessage(res?.data?.message || 'Login failed. Please check your credentials.', 'error');
}
}