feat: replace is_pro boolean with entitlements array in JWT claims#2179
Merged
feat: replace is_pro boolean with entitlements array in JWT claims#2179
Conversation
…n status - Add new migration to update custom_access_token_hook to check active_entitlements - Check for lookup_key='pro' instead of any active/trialing subscription - Update tests to verify entitlements-based is_pro logic - More robust: only grants pro status for specific feature entitlement, not any subscription Requires creating a Feature in Stripe Dashboard with lookup_key='pro' and attaching it to the Pro product. Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
✅ Deploy Preview for hyprnote-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
Per user request, merged the entitlements-based is_pro logic directly into the original auth hook migration since production DB is still clean. Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
- Auth hook now returns entitlements: ['hyprnote_pro', ...] array with all user's active entitlements
- billing.tsx derives isPro from entitlements.includes('hyprnote_pro')
- Also exposes entitlements array for future feature gating
- Updated tests to verify entitlements array structure
This is more future-proof: adding new Stripe Features requires no code changes.
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the
is_proboolean JWT claim with a more flexibleentitlementsarray containing all of the user's active Stripe Entitlements. This is more future-proof: adding new Stripe Features requires no code changes.Before:
{ "is_pro": true }based on any active/trialing subscriptionAfter:
{ "entitlements": ["hyprnote_pro", "other_feature", ...] }based on Stripe active_entitlementsThe frontend (
billing.tsx) now:entitlements: string[]for future feature gatingisProfromentitlements.includes("hyprnote_pro")Review & Testing Checklist for Human
lookup_key = 'hyprnote_pro'and attach it to your Pro product BEFORE deploying. Without this, all Pro users will lose access.stripe.active_entitlementstable is being populated by stripe-sync-engine webhooks in your environmentis_proboolean (this is a breaking change to JWT structure)entitlements: ["hyprnote_pro"]in their JWT after migrationsupabase test dbto verify the test cases passRecommended test plan:
hyprnote_prosupabase migration up --localto apply the migrationsupabase test dbto verify tests passstripe.active_entitlementsentitlements: ["hyprnote_pro"]for the subscribed userNotes
lookup_key = 'hyprnote_pro'is hardcoded inbilling.tsx. If you want a different key, update both the Stripe Feature and the frontend code.entitlementsarray is sorted alphabetically and will contain all active entitlements for the user.Link to Devin run: https://app.devin.ai/sessions/e407499d03e44a6881ccea898edda98d
Requested by: yujonglee (@yujonglee)