Menu

1 / 2

Our device cap is written only by the Stripe webhook, so the one plan with a cap of 2 is the one nobody can reach

DEV Community: redis·Daniel Pertu·about 17 hours ago
#MUcDGWl1
#devtoredis#devto#dev#fullscreen#session
Reading 0:00
15s threshold

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 ?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.