mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 15:19:08 +03:00
fix: disallow self-serve downgrades from Enterprise/Team
This commit is contained in:
1 parent
bf76b83b6d
commit
0945e7cfd6
4 files changed
+51
-7
No files matched your search
@@ -41,10 +41,20 @@ const BillingUpdateEnterprise: NextPageWithLayout = () => {
|
||||
}, [orgSlug])
|
||||
|
||||
useEffect(() => {
|
||||
if (subscription !== undefined && !isEnterprise) {
|
||||
router.push(`/project/${projectRef}/settings/billing/update`)
|
||||
if (subscription && !isEnterprise) {
|
||||
if (subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.TEAM) {
|
||||
router.push(`/project/${projectRef}/settings/billing/update/team`)
|
||||
} else if (
|
||||
[PRICING_TIER_PRODUCT_IDS.PAYG, PRICING_TIER_PRODUCT_IDS.PRO].includes(
|
||||
subscription.tier.supabase_prod_id
|
||||
)
|
||||
) {
|
||||
router.push(`/project/${projectRef}/settings/billing/update/pro`)
|
||||
} else {
|
||||
router.push(`/project/${projectRef}/settings/billing/update`)
|
||||
}
|
||||
}
|
||||
}, [subscription])
|
||||
}, [subscription, isEnterprise, projectRef, router])
|
||||
|
||||
const getStripeProducts = async () => {
|
||||
try {
|
||||
|
||||
@@ -30,10 +30,17 @@ const BillingUpdateFree: NextPageWithLayout = () => {
|
||||
}, [projectRef])
|
||||
|
||||
useEffect(() => {
|
||||
if (isEnterprise) {
|
||||
if (subscription?.tier?.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISE) {
|
||||
// no self-serve downgrade from Enterprise
|
||||
router.push(`/project/${projectRef}/settings/billing/update/enterprise`)
|
||||
} else if (subscription?.tier?.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.TEAM) {
|
||||
// no self-serve downgrade from Team
|
||||
router.push(`/project/${projectRef}/settings/billing/update/team`)
|
||||
} else if (subscription?.tier?.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.FREE) {
|
||||
// Downgrade from free to free is not possible, so let's redirect
|
||||
router.push(`/project/${projectRef}/settings/billing/update`)
|
||||
}
|
||||
}, [subscription])
|
||||
}, [subscription, projectRef, router])
|
||||
|
||||
const getStripeProducts = async () => {
|
||||
try {
|
||||
|
||||
@@ -36,6 +36,21 @@ const BillingUpdatePro: NextPageWithLayout = () => {
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
subscription &&
|
||||
![PRICING_TIER_PRODUCT_IDS.PAYG, PRICING_TIER_PRODUCT_IDS.PRO].includes(
|
||||
subscription.tier.supabase_prod_id
|
||||
)
|
||||
) {
|
||||
if (subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISE) {
|
||||
router.push(`/project/${projectRef}/settings/billing/update/enterprise`)
|
||||
} else if (subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.TEAM) {
|
||||
router.push(`/project/${projectRef}/settings/billing/update/team`)
|
||||
}
|
||||
}
|
||||
}, [subscription, projectRef, router])
|
||||
|
||||
useEffect(() => {
|
||||
if (projectRef) {
|
||||
getStripeProducts()
|
||||
|
||||
@@ -50,10 +50,22 @@ const BillingUpdateTeam: NextPageWithLayout = () => {
|
||||
}, [orgSlug])
|
||||
|
||||
useEffect(() => {
|
||||
if (isEnterprise) {
|
||||
if (subscription?.tier?.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISE) {
|
||||
router.push(`/project/${projectRef}/settings/billing/update/enterprise`)
|
||||
} else if (
|
||||
subscription &&
|
||||
[PRICING_TIER_PRODUCT_IDS.PAYG, PRICING_TIER_PRODUCT_IDS.PRO].includes(
|
||||
subscription.tier.supabase_prod_id
|
||||
)
|
||||
) {
|
||||
router.push(`/project/${projectRef}/settings/billing/update/pro`)
|
||||
} else if (
|
||||
subscription &&
|
||||
subscription.tier.supabase_prod_id !== PRICING_TIER_PRODUCT_IDS.TEAM
|
||||
) {
|
||||
router.push(`/project/${projectRef}/settings/billing/update`)
|
||||
}
|
||||
}, [subscription])
|
||||
}, [subscription, projectRef, router])
|
||||
|
||||
const getStripeProducts = async () => {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user