fix(myTischtennis): add detailed diagnostics for login failures
- Introduced failure diagnostics logging during the login process to capture URL, cookie names, and body preview on errors. - Enhanced error handling to provide clearer insights into login issues, particularly related to CAPTCHA and password failures. - Improved console warnings for better visibility into authentication problems encountered during login attempts.
This commit is contained in:
@@ -585,6 +585,7 @@ class MyTischtennisClient {
|
||||
}
|
||||
if (!authCookieObj || !authCookieObj.value) {
|
||||
let errorText = null;
|
||||
let failureDiagnostics = null;
|
||||
try {
|
||||
const textContent = await page.locator('body').innerText({ timeout: 1000 });
|
||||
if (textContent?.includes('Captcha-Bestätigung fehlgeschlagen')) {
|
||||
@@ -593,12 +594,24 @@ class MyTischtennisClient {
|
||||
if (!errorText && textContent?.includes('Passwort')) {
|
||||
errorText = 'Login vermutlich fehlgeschlagen (Passwort oder CAPTCHA)';
|
||||
}
|
||||
|
||||
const currentUrl = page.url();
|
||||
const allCookies = await context.cookies();
|
||||
const cookieNames = allCookies.map((c) => c.name);
|
||||
failureDiagnostics = {
|
||||
url: currentUrl,
|
||||
cookieNames,
|
||||
bodyPreview: String(textContent || '').slice(0, 320)
|
||||
};
|
||||
} catch (_e) {
|
||||
// ignore text read errors
|
||||
}
|
||||
if (!errorText && detectedSubmitError) {
|
||||
errorText = detectedSubmitError;
|
||||
}
|
||||
if (failureDiagnostics) {
|
||||
console.warn('[myTischtennisClient.playwright] Login failure diagnostics:', failureDiagnostics);
|
||||
}
|
||||
return {
|
||||
success: false,
|
||||
error: errorText
|
||||
|
||||
Reference in New Issue
Block a user