fix(vidmoly): probe /api/upload/config to verify login

The old /my HTML check failed because it couldn't distinguish an XFS
session from a full SPA session. Since /api/upload/config is what the
upload actually needs, probe it directly after login — 200 JSON with
sess_id/upload_url means we're good, anything else means we're out.
This commit is contained in:
Administrator 2026-04-19 22:27:49 +02:00
parent d0c9df7656
commit 5c7bfb48b9

View File

@ -111,20 +111,19 @@ class VidmolyUploader {
throw new Error('Vidmoly Login fehlgeschlagen: Falscher Username oder Passwort'); throw new Error('Vidmoly Login fehlgeschlagen: Falscher Username oder Passwort');
} }
// Verify session by hitting the new SPA dashboard at /my. On the old XFS // Verify by directly probing the upload-config API. If we get a valid
// site the login page included a <form name="password">; the SPA dashboard // JSON with sess_id/upload_url back, we're in. This is the only thing
// doesn't contain that form when the session is valid (it's rendered by // we actually need to work, so check it up front instead of guessing
// JS), so the absence of a password field + presence of any known marker // from SPA HTML markers.
// (Dashboard / Logout / the user's own username) indicates we're in.
if (this.cookies.size === 0) { if (this.cookies.size === 0) {
throw new Error('Vidmoly Login fehlgeschlagen: Keine Session erhalten'); throw new Error('Vidmoly Login fehlgeschlagen: Keine Session erhalten');
} }
const verifyRes = await this._fetch(`${BASE_URL}/my`); const probe = await this._fetch(`${BASE_URL}/api/upload/config`);
const verifyBody = await verifyRes.text(); const probeBody = await probe.text();
const hasPasswordForm = /<form[^>]*>[\s\S]{0,800}?name=["']password["']/i.test(verifyBody); let probeJson = null;
const hasDashboardMarker = /(?:Dashboard|Video[- ]Manager|Logout|dashboard|my[_ -]?(account|files))/i.test(verifyBody); try { probeJson = JSON.parse(probeBody); } catch {}
if (hasPasswordForm || !hasDashboardMarker) { if (!probeJson || !probeJson.sess_id || !probeJson.upload_url) {
throw new Error('Vidmoly Login fehlgeschlagen: Session konnte nicht verifiziert werden'); throw new Error('Vidmoly Login fehlgeschlagen: Session konnte nicht verifiziert werden (API-Probe)');
} }
} }