Fix License Management: auth middleware bug, Sidebar integration, and upgrade flow#29
Draft
Copilot wants to merge 2 commits into
Draft
Fix License Management: auth middleware bug, Sidebar integration, and upgrade flow#29Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Fix auth middleware: use `?? 0` for free_usage instead of falsy check that incorrectly reset counter; remove unnecessary updateUserMetadata call for premium users - Add ManagePlan page with Clerk PricingTable for in-app plan management - Add /ai/manage-plan route in App.jsx - Integrate Sidebar into Layout with sidebar state and mobile overlay - Enhance Sidebar with PRO badges on premium-only features and Manage Plan link - Update Navbar to accept setSidebar prop for toggling Sidebar on mobile - Add test for manage-plan route Agent-Logs-Url: https://github.com/VisibleNasir/VisibleKAi/sessions/bd9958b4-90b2-4991-a9a3-95b3a0742cea Co-authored-by: VisibleNasir <109416738+VisibleNasir@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix license management implementation issue
Fix License Management: auth middleware bug, Sidebar integration, and upgrade flow
Apr 1, 2026
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.
License management was broken in multiple ways: the auth middleware had a falsy-check bug that caused incorrect behavior for free users with
free_usage === 0and made unnecessary Clerk API calls on every premium request; theSidebarcomponent (with plan display) was never mounted; and free users had no in-app path to upgrade.Server
middlewares/auth.js: Replaceuser.privateMetadata.free_usage(falsy on0) with?? 0. Remove theupdateUserMetadatacall from theelsebranch — premium users no longer trigger a metadata write on every request.Client
Layout.jsx: MountSidebaralongside the outlet; managesidebaropen/close state here; add a mobile backdrop overlay.Sidebar.jsx: AddPRObadges on premium-only nav items (shown to free users only via Clerk<Protect>); add a Manage Plan nav link.Navbar.jsx: Accept optionalsetSidebarprop — hamburger toggles the Sidebar when in the AI section instead of the inline dropdown.pages/ManagePlan.jsx(new): Dedicated/ai/manage-planroute rendering Clerk's<PricingTable>alongside the user's current plan, giving free users a direct upgrade path from within the app.App.jsx: Register themanage-planroute.