Closed teodorus-nathaniel closed 3 weeks ago
The changes in the pull request focus on the GET
request handler in the src/routes/api/github/auth/profile/+server.ts
file. The updated logic manages user authentication tokens by checking for an accessToken
in cookies and attempting to refresh it using a refreshToken
if the access token is absent. Upon successful refresh, the new tokens are stored in cookies. If no tokens are available, a JSON response with a null
user is returned. The handler then fetches user data from the GitHub API using the valid accessToken
and returns it in a consistent JSON format.
File Path | Change Summary |
---|---|
src/routes/api/github/auth/profile/+server.ts | Modified GET request handler to manage user authentication tokens, including logic for refreshing tokens and fetching user data from GitHub API. |
sequenceDiagram
participant Client
participant Server
participant GitHubAPI
Client->>Server: GET request
Server->>Server: Check for accessToken in cookies
alt accessToken present
Server->>GitHubAPI: Fetch user data with accessToken
GitHubAPI-->>Server: Return user data
else refreshToken present
Server->>Server: Refresh accessToken using refreshToken
Server->>GitHubAPI: Fetch user data with new accessToken
GitHubAPI-->>Server: Return user data
else no tokens
Server-->>Client: Return JSON with null user
end
Server-->>Client: Return JSON with user data
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@teodorus-nathaniel ⚠️⚠️⚠️ You must submit the time spent on this PR. ⚠️⚠️⚠️
Test Comment
Comment
Comment
Summary by CodeRabbit
New Features
Bug Fixes