fix(core): return user and expires in session#236
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
📝 WalkthroughWalkthroughSession parsing now returns structured ChangesStateless session contract
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/api/refreshUserInfo.ts`:
- Around line 94-106: Update the refresh response construction around
getStandardSession so a null parsed session is treated as a refresh failure
instead of returning status 200 with success false. Before returning the
RefreshUserInfoAPIReturn, either throw the parsing error or clear the newly
issued session cookie and return an appropriate error response; ensure malformed
provider profiles cannot replace a valid session with an unusable token.
In `@packages/core/test/api/stateless/getSession.test.ts`:
- Around line 104-105: Update both decoded-cookie assertions in
packages/core/test/api/stateless/getSession.test.ts at lines 104-105 and 135-136
to explicitly verify the refreshed session cookies do not contain role or
permissions, while retaining the existing sessionPayload matching. Apply the
same absence checks to the rolling-refresh cookie assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 813312f1-93cb-48e3-9125-ee1fc761a29c
📒 Files selected for processing (5)
packages/core/src/api/refreshUserInfo.tspackages/core/src/shared/utils.tspackages/core/test/actions/providers/user/stateless.test.tspackages/core/test/api/stateless/getSession.test.tspackages/core/test/api/stateless/refreshUserInfo.test.ts
Description
This pull request fixes the session returned by the
refreshUserInfo()APIs (both the server-side API and the HTTP endpoint).Previously,
refreshUserInfo()returned an incomplete session object that omitted theuserandexpiresfields, making its response inconsistent with other session-related APIs such asapi.getSession()andapi.updateSession().With this change,
refreshUserInfo()now returns the complete session object, providing a consistent API across all session management functions.Key Changes
refreshUserInfo().userfield to the returned session.expiresfield to the returned session.api.getSession()andapi.updateSession().Comparison
{ + user: { sub: "1234567890", name: "John Doe", email: "john@example.com", image: "https://image.com", }, + expires: "2026-01-01T00:00:00Z" }