31 lines
989 B
JavaScript
31 lines
989 B
JavaScript
async function login(username, password) {
|
|
console.log("Login function called!"); // Debugging
|
|
|
|
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", {
|
|
method: "POST",
|
|
headers: {
|
|
"Authorization": authHeader,
|
|
"Content-Type": "application/json"
|
|
}
|
|
});
|
|
|
|
console.log("Response received:", response);
|
|
|
|
if (response.ok) {
|
|
console.log("Login successful");
|
|
return true;
|
|
} else {
|
|
console.log("Login failed with status:", response.status, response.statusText);
|
|
const errorText = await response.text();
|
|
console.log("Response body:", errorText);
|
|
return false;
|
|
}
|
|
} catch (error) {
|
|
console.error("Fetch error:", error);
|
|
return false;
|
|
}
|
|
}
|