Don't allow personal and non-personal keys at the same time

This commit is contained in:
Owen
2026-09-22 10:40:47 -04:00
parent d38281b9f7
commit 70f677a277
+29
View File
@@ -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.