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. If absent, it attempts to refresh the token using a refreshToken
. The new tokens are set in cookies, and user data is fetched from the GitHub API if valid tokens are present. The response structure is adjusted to return user data or a null user based on token availability.
File Path | Change Summary |
---|---|
src/routes/api/github/auth/profile/+server.ts | Modified the GET request handler to manage user authentication tokens, including token refresh logic and response handling. |
sequenceDiagram
participant Client
participant Server
participant GitHubAPI
Client->>Server: GET /api/github/auth/profile
Server->>Server: Check cookies for accessToken
alt accessToken present
Server->>GitHubAPI: Fetch user data with accessToken
GitHubAPI-->>Server: Return user data
Server-->>Client: Return user data (200)
else refreshToken present
Server->>Server: Call refreshUserToken()
Server-->>Server: Set new accessToken and refreshToken in cookies
Server->>GitHubAPI: Fetch user data with new accessToken
GitHubAPI-->>Server: Return user data
Server-->>Client: Return user data (200)
else no tokens
Server-->>Client: Return null user (200)
end
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?
Comment
Plain
Update
New
Comment
@teodorus-nathaniel ⚠️⚠️⚠️ You must submit the time spent on this PR. ⚠️⚠️⚠️
@teodorus-nathaniel ⚠️⚠️⚠️ You must submit the time spent on this PR. ⚠️⚠️⚠️
Summary by CodeRabbit
New Features
Bug Fixes