Add userId validation to subscription pause/resume endpoints#51
Add userId validation to subscription pause/resume endpoints#51
Conversation
Previously, the pause subscription feature relied solely on session state to determine which user to pause. When an admin was viewing as another user, if the session's viewingAsUserId was stale or not properly synced with the client, the pause action would fall back to the admin's own userId, pausing their own subscription instead of the target user's. This fix: - Passes the explicit userId from the server-rendered page to the client - Includes userId in pause/resume API requests - Adds authorization checks to validate the userId matches either the caller's own account or their view-as target https://claude.ai/code/session_01UCFbRRcHm9tQ3PfqLT8JC9
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
|
@claude this still doesn't seem to work; I tried again as Ventali while in admin mode as myself (Rachel Shu), and it paused me again rather than ventali. this might also be connected to an issue where when I refresh, it doesn't preserve the previous 'logged in as', but rather always resets to operating as myself |
|
Claude finished @wearsshoes's task in 2m 17s —— View job Investigating subscription pause bug
|
Co-authored-by: Rachel Shu <wearsshoes@users.noreply.github.com>

Summary
Enhanced security for subscription pause and resume operations by adding explicit
userIdvalidation to both the frontend component and backend API endpoints. This ensures that users can only pause/resume their own subscriptions, while staff members can only perform these actions on behalf of users they're explicitly viewing as.Key Changes
userIdprop and passed it to both pause and resume API requestsuserIdfrom request bodyuserIdis provideduserIdinstead of deriving it from sessionuserIdeffectiveUserIdto SubscriptionInfo componentImplementation Details
userIdmatches eithersession.userId(own account) orsession.viewingAsUserId(staff viewing as another user)userIdis missing, 403 if unauthorizedisOwnAccountandisViewingAsTargetvariableshttps://claude.ai/code/session_01UCFbRRcHm9tQ3PfqLT8JC9