PubTrivia is sold per venue, and the thing we are guarding against is one login being passed around: the plans are priced for a pub, not for a chain sharing a password. So each account has a cap on how many browsers can be signed in at once, and the caps are declared in utils/plan-limits.ts along with every other limit:
trial : { maxConcurrentLogins : 2 , // one venue device + one home device }, pro : { maxConcurrentLogins : 3 , // backstop against credential sharing }, ultimate : { maxConcurrentLogins : 3 , // per-account cap (each of the 5 seats gets 3) },
Enter fullscreen mode
Exit fullscreen mode
Two, three, three. Hold onto those numbers, because the enforcement path makes one of them unreachable.
How the cap is enforced
The cap is a Redis key, read in the proxy on every dashboard request:
// Read the per-user cap from Redis (written by the Stripe webhook // when a subscription activates). Fall back to 3 if not set. const capKey = ` ${ KEY_PREFIX } :cap: ${ user . id } ` const storedCap = redis ?…