-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Move the partner permission checks to withPartnerProfile
middleware
#2969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR refactors permission enforcement in partner-profile API routes by centralizing permission checks at the middleware wrapper level. The Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant Wrapper as withPartnerProfile
participant Handler as Route Handler
participant PermCheck as Permission Checker
participant DB as Database
Note over Wrapper,Handler: Old Flow (removed)
Client->>Wrapper: Request
Wrapper->>Handler: Pass partnerUser
Handler->>PermCheck: throwIfNoPermission(role, permission)
alt Permission denied
PermCheck-->>Handler: Throw error
Handler-->>Client: 403 Forbidden
else Permission granted
Handler->>DB: Process request
DB-->>Handler: Result
Handler-->>Client: Response
end
Note over Wrapper,Handler: New Flow (added)
Client->>Wrapper: Request
Wrapper->>PermCheck: Check requiredPermission?
alt Permission denied
PermCheck-->>Wrapper: Throw error
Wrapper-->>Client: 403 Forbidden
else Permission granted
Wrapper->>Handler: Call handler (no partnerUser)
Handler->>DB: Process request
DB-->>Handler: Result
Handler-->>Client: Response
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The changes follow a consistent refactoring pattern across multiple routes, reducing review complexity. However, the centralized permission enforcement logic in Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used🧬 Code graph analysis (1)apps/web/lib/auth/partner.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (14)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit