fix(catalog): fall back to de account when tr serves a PL24 demo page
Hyundai/Kia/Nissan parts-drilling returned a NOT_LOGGED_IN_DEMO page on the tr account (license-gated), so live drills yielded 0 parts even though the tree loads. After the tr re-auth retry still demos, try the de account once; if it serves real (non-demo) content, use it. Tests whether de holds the brand license. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3256,17 +3256,38 @@ export class PL24FordLegacyService {
|
||||
|
||||
const html = await response.text();
|
||||
// Demo mode: PL24 serves a stripped NOT_LOGGED_IN_DEMO page (no real
|
||||
// groups/parts) when the service token is stale. decodeVinForService
|
||||
// retries on this, but drill paths reach upstream only through here —
|
||||
// so retry once with fresh auth before parsing an empty page.
|
||||
if (!retried && html.includes("PL24_SUPPORT")) {
|
||||
const support = this.extractScriptVariable<FordPL24Support>(html, "PL24_SUPPORT");
|
||||
if (support?.demo || support?.role === "NOT_LOGGED_IN_DEMO") {
|
||||
this.logger.warn(`Ford legacy: demo page for ${serviceName}, re-authing + retry`);
|
||||
// groups/parts) when the service token is stale OR the account is not
|
||||
// licensed for this brand. Retry once with fresh auth; if still demo on the
|
||||
// primary (tr) account, fall back to the secondary (de) account whose
|
||||
// license set may include this brand (e.g. Hyundai/Kia/Nissan parts).
|
||||
const supportOf = (h: string) =>
|
||||
h.includes("PL24_SUPPORT")
|
||||
? this.extractScriptVariable<FordPL24Support>(h, "PL24_SUPPORT")
|
||||
: null;
|
||||
const isDemo = (h: string) => {
|
||||
const s = supportOf(h);
|
||||
return !!(s?.demo || s?.role === "NOT_LOGGED_IN_DEMO");
|
||||
};
|
||||
if (isDemo(html)) {
|
||||
if (!retried) {
|
||||
this.logger.warn(`Ford legacy: demo page for ${serviceName} (account=${account}), re-auth + retry`);
|
||||
this.authService.clearTokensForAccount(account);
|
||||
await this.authService.authorizeServiceForAccount(serviceName, account);
|
||||
return this.fetchP4Page(url, serviceName, isFullUrl, account, true);
|
||||
}
|
||||
if (account === "tr") {
|
||||
// License may live on the de account — try it once (own re-auth allowed).
|
||||
try {
|
||||
await this.authService.authorizeServiceForAccount(serviceName, "de");
|
||||
const deHtml = await this.fetchP4Page(url, serviceName, isFullUrl, "de", false);
|
||||
if (deHtml && !isDemo(deHtml)) {
|
||||
this.logger.log(`Ford legacy: ${serviceName} served by de account (tr was demo)`);
|
||||
return deHtml;
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.warn(`Ford legacy: de fallback failed for ${serviceName}: ${(e as Error).message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return html;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user