Compare commits

..

No commits in common. "f025794a2754296ebea87a61b7d772b73d1f0464" and "00831bb0c2c8b56504ace0d00ddd8c47a9ba5c3f" have entirely different histories.

2 changed files with 20 additions and 55 deletions

View file

@ -1,10 +1,6 @@
async function login(username, password) { async function login(username, password) {
console.log("Login function called!"); // Debugging
const authHeader = "Basic " + btoa(username + ":" + password); const authHeader = "Basic " + btoa(username + ":" + password);
try {
console.log("Sending request to SOGo API...");
const response = await fetch("https://mail.pandem.fr/SOGo/so/session", { const response = await fetch("https://mail.pandem.fr/SOGo/so/session", {
method: "POST", method: "POST",
headers: { headers: {
@ -13,19 +9,9 @@ async function login(username, password) {
} }
}); });
console.log("Response received:", response);
if (response.ok) { if (response.ok) {
console.log("Login successful"); return true; // Successfully logged in
return true;
} else { } else {
console.log("Login failed with status:", response.status, response.statusText); return false; // Login failed
const errorText = await response.text();
console.log("Response body:", errorText);
return false;
}
} catch (error) {
console.error("Fetch error:", error);
return false;
} }
} }

View file

@ -1,33 +1,12 @@
document.addEventListener("DOMContentLoaded", function () { document.getElementById("login-btn").addEventListener("click", async () => {
console.log("Popup loaded!"); // Debugging
document.getElementById("login-btn").addEventListener("click", async () => {
console.log("Login button clicked!"); // Debugging
const username = document.getElementById("email").value; const username = document.getElementById("email").value;
const password = document.getElementById("password").value; const password = document.getElementById("password").value;
if (!username || !password) {
console.log("Missing username or password");
document.getElementById("status").innerText = "Please enter both email and password.";
return;
}
console.log("Attempting login..."); // Debugging
try {
const success = await login(username, password); const success = await login(username, password);
if (success) { if (success) {
document.getElementById("status").innerText = "Login Successful!"; document.getElementById("status").innerText = "Login Successful!";
console.log("Login successful!");
} else { } else {
document.getElementById("status").innerText = "Login Failed!"; document.getElementById("status").innerText = "Login Failed!";
console.log("Login failed!");
} }
} catch (error) {
console.error("Login error:", error);
document.getElementById("status").innerText = "An error occurred.";
}
});
}); });