add logging to main auth
This commit is contained in:
parent
2072aa30ef
commit
6cb764faf7
@ -23,12 +23,23 @@ let authToken = null;
|
|||||||
|
|
||||||
// --- EVENT HANDLERS (The "Logic") ---
|
// --- EVENT HANDLERS (The "Logic") ---
|
||||||
async function handleAuthSubmit(e) {
|
async function handleAuthSubmit(e) {
|
||||||
|
console.log("1. Form submitted, handleAuthSubmit function started."); // Checkpoint 1
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const username = e.target.elements.username.value;
|
const username = e.target.elements.username.value;
|
||||||
const password = e.target.elements.password.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 });
|
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();
|
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user