From 70f677a2775c3d17c9d2c970cafc7938464e6ea8 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 22 Sep 2026 10:40:47 -0400 Subject: [PATCH] Don't allow personal and non-personal keys at the same time --- server/private/license/license.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/server/private/license/license.ts b/server/private/license/license.ts index 25eac8bc5..16a62c042 100644 --- a/server/private/license/license.ts +++ b/server/private/license/license.ts @@ -401,6 +401,35 @@ LQIDAQAB } } + // Personal-tier licenses cannot coexist with a paid tier: if any + // valid host key is above personal, personal-tier keys are + // invalidated so they don't contribute to the totals below. + const hasHigherTierValidKey = keys.some((key) => { + const cached = newCache.get(key.licenseKey)!; + return ( + cached.type === "host" && + cached.valid && + tierRank(cached.tier) > tierRank("personal") + ); + }); + + if (hasHigherTierValidKey) { + for (const key of keys) { + const cached = newCache.get(key.licenseKey)!; + if ( + cached.type === "host" && + cached.valid && + cached.tier === "personal" + ) { + logger.debug( + `Invalidating personal license key ${key.licenseKey} because a higher tier license is present` + ); + cached.valid = false; + newCache.set(key.licenseKey, cached); + } + } + } + // Compute host status: quantity = users, quantity_2 = sites // When multiple host keys are active, prefer a valid key over an // invalid one, and among equally-valid keys prefer the highest tier.