-
Notifications
You must be signed in to change notification settings - Fork 140
feat(auth): refactor frontend auth helpers and supabase client #152
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
WalkthroughA new frontend API layer is introduced for collaborations and creators, paired with enhanced authentication token management including automatic refresh capabilities and improved error handling in auth helper functions. Changes
Sequence DiagramsequenceDiagram
actor Client
participant AF as authenticatedFetch
participant AH as auth-helpers
participant SC as supabaseClient
participant API as Backend API
Client->>AF: fetch(url, options)
AF->>AH: getToken via ensureValidToken
AH->>SC: getAuthToken()
SC-->>AH: token or undefined
alt Token exists
AF->>AF: append Authorization header
else No token
AH->>SC: refreshAuthToken()
SC->>API: refresh_session
API-->>SC: new token
SC-->>AH: new token
AF->>AF: append Authorization header
end
AF->>API: fetch with auth header
API-->>AF: response
alt 401 Unauthorized
AF->>SC: refreshAuthToken()
SC->>API: refresh_session
API-->>SC: new token
SC-->>AF: new token
AF->>API: retry fetch with new token
API-->>AF: response (retry result)
end
AF-->>Client: return Response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
frontend/lib/api/collaborations.ts(1 hunks)frontend/lib/api/creators.ts(1 hunks)frontend/lib/auth-helpers.ts(5 hunks)frontend/lib/supabaseClient.ts(1 hunks)
📝 Description
This pull request refactors the frontend authentication helpers and Supabase client integration to improve authentication flow, maintainability, and code clarity. It also introduces a new API utility directory for better modularity.
🔧 Changes Made
✅ Checklist
Summary by CodeRabbit