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 <noreply@anthropic.com>
This commit is contained in:
parent
ec2bbad4a2
commit
d791414f27
@ -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; });
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user