From d791414f27ec608ef9c3f9aeac4eb4142613eb95 Mon Sep 17 00:00:00 2001 From: MOHAN Date: Thu, 11 Jun 2026 13:46:13 +0530 Subject: [PATCH] fix: bypass subscription gate for free-access shops on brands/manage-brand pages Both app.brands.jsx and app.managebrand.jsx now call /free-access/:shop after a negative subscription check, mirroring the fix already applied in app._index.jsx. Affects both loader (UI lock) and action (import guard). Co-Authored-By: Claude Sonnet 4.6 --- app/routes/app.brands.jsx | 22 ++++++++++++++++++---- app/routes/app.managebrand.jsx | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/app/routes/app.brands.jsx b/app/routes/app.brands.jsx index caf1e21..a197fd9 100644 --- a/app/routes/app.brands.jsx +++ b/app/routes/app.brands.jsx @@ -103,7 +103,14 @@ export const loader = async ({ request }) => { return json({ brands: [], collections: [], selectedBrandsFromShopify: [], shop: "", error: "Shopify authentication failed", isSubscribed: false, subscription: null }); } - const { isSubscribed, subscription } = await getSubscriptionDetails(request); + let { isSubscribed, subscription } = await getSubscriptionDetails(request); + if (!isSubscribed) { + try { + const far = await fetch(`https://backend.data4autos.com/free-access/${encodeURIComponent(shop)}`); + const fad = await far.json(); + if (fad.allowed === true) isSubscribed = true; + } catch {} + } let accessToken = ""; try { accessToken = await getTurn14AccessTokenFromMetafield(request); @@ -139,14 +146,21 @@ export const loader = async ({ request }) => { }; export const action = async ({ request }) => { - const { isSubscribed } = await getSubscriptionDetails(request); + const { session } = await authenticate.admin(request); + const shop = session.shop; + let { isSubscribed } = await getSubscriptionDetails(request); + if (!isSubscribed) { + try { + const far = await fetch(`https://backend.data4autos.com/free-access/${encodeURIComponent(shop)}`); + const fad = await far.json(); + if (fad.allowed === true) isSubscribed = true; + } catch {} + } if (!isSubscribed) return json({ error: "An active subscription or free trial is required to save brand collections." }, { status: 403 }); const formData = await request.formData(); const selectedBrands = JSON.parse(formData.get("selectedBrands") || "[]"); const selectedOldBrands = JSON.parse(formData.get("selectedOldBrands") || "[]"); - const { session } = await authenticate.admin(request); - const shop = session.shop; selectedBrands.forEach((brand) => { delete brand.pricegroups; }); selectedOldBrands.forEach((brand) => { delete brand.pricegroups; }); diff --git a/app/routes/app.managebrand.jsx b/app/routes/app.managebrand.jsx index 3c64fc9..a1a3f7a 100644 --- a/app/routes/app.managebrand.jsx +++ b/app/routes/app.managebrand.jsx @@ -98,7 +98,14 @@ export const loader = async ({ request }) => { const { admin } = await authenticate.admin(request); const { session } = await authenticate.admin(request); const shop = session.shop; - const { isSubscribed, subscription } = await getSubscriptionDetails(request); + let { isSubscribed, subscription } = await getSubscriptionDetails(request); + if (!isSubscribed) { + try { + const far = await fetch(`https://backend.data4autos.com/free-access/${encodeURIComponent(shop)}`); + const fad = await far.json(); + if (fad.allowed === true) isSubscribed = true; + } catch {} + } let accessToken = ""; try { @@ -145,7 +152,16 @@ const makes_list_raw = [ const makes_list = makes_list_raw.sort(); export const action = async ({ request }) => { - const { isSubscribed } = await getSubscriptionDetails(request); + const { session } = await authenticate.admin(request); + const shop = session.shop; + let { isSubscribed } = await getSubscriptionDetails(request); + if (!isSubscribed) { + try { + const far = await fetch(`https://backend.data4autos.com/free-access/${encodeURIComponent(shop)}`); + const fad = await far.json(); + if (fad.allowed === true) isSubscribed = true; + } catch {} + } if (!isSubscribed) return json({ error: "An active subscription or free trial is required to add products." }, { status: 403 }); const { admin } = await authenticate.admin(request);