Propagate unlimited website entitlement through subscription checks
This commit is contained in:
@@ -22,6 +22,7 @@ export async function POST(request: Request) {
|
||||
isBusiness: account.isBusiness || false,
|
||||
isNoBilling: account.isNoBilling || false,
|
||||
hasSubscription: account.hasSubscription || false,
|
||||
unlimitedWebsites: account.unlimitedWebsites || false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -36,6 +37,7 @@ export async function POST(request: Request) {
|
||||
isBusiness: teamAccount.isBusiness || false,
|
||||
isNoBilling: teamAccount.isNoBilling || false,
|
||||
hasSubscription: teamAccount.hasSubscription || false,
|
||||
unlimitedWebsites: teamAccount.unlimitedWebsites || false,
|
||||
}
|
||||
: null,
|
||||
};
|
||||
|
||||
@@ -70,6 +70,7 @@ export async function POST(request: Request) {
|
||||
isBusiness: account.isBusiness || false,
|
||||
isNoBilling: account.isNoBilling || false,
|
||||
hasSubscription: account.hasSubscription || false,
|
||||
unlimitedWebsites: account.unlimitedWebsites || false,
|
||||
},
|
||||
60 * 60 * 24 * 90,
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface Subscription {
|
||||
isBusiness: boolean;
|
||||
isNoBilling: boolean;
|
||||
hasSubscription: boolean;
|
||||
unlimitedWebsites: boolean;
|
||||
}
|
||||
|
||||
const FEATURES = {
|
||||
@@ -19,6 +20,7 @@ const defaultSubscription: Subscription = {
|
||||
isBusiness: false,
|
||||
isNoBilling: false,
|
||||
hasSubscription: false,
|
||||
unlimitedWebsites: false,
|
||||
};
|
||||
|
||||
export function useSubscription(teamId?: string | null) {
|
||||
|
||||
@@ -28,4 +28,18 @@ describe('getCloudWebsiteLimit', () => {
|
||||
expect(getCloudWebsiteLimit({ hasSubscription: true, isBusiness: true })).toBeNull();
|
||||
expect(getCloudWebsiteLimit({ hasSubscription: true, isNoBilling: true })).toBeNull();
|
||||
});
|
||||
|
||||
// Team-owned websites pass the team cache object (derived from the team owner's account)
|
||||
// through this same function, so members inherit the owner's unlimitedWebsites entitlement.
|
||||
test('does not limit teams that inherit unlimited websites from a subscribed owner', () => {
|
||||
expect(
|
||||
getCloudWebsiteLimit({ hasSubscription: true, isPro: true, unlimitedWebsites: true }),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
test('still limits teams whose owner has no subscription even if unlimited websites is set', () => {
|
||||
expect(
|
||||
getCloudWebsiteLimit({ hasSubscription: false, unlimitedWebsites: true }),
|
||||
).toBe(CLOUD_FREE_WEBSITE_LIMIT);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user