Fix GitHub user cache consistency and fallback session shape#296
Open
Esubaalew wants to merge 1 commit intobetter-auth:mainfrom
Open
Fix GitHub user cache consistency and fallback session shape#296Esubaalew wants to merge 1 commit intobetter-auth:mainfrom
Esubaalew wants to merge 1 commit intobetter-auth:mainfrom
Conversation
Keep cached GitHub profile reads and writes on the same key, and make degraded GitHub user sessions fail safely instead of returning an incomplete object.
|
@Esubaalew is attempting to deploy a commit to the better-auth Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes the GitHub user cache by making the read and write paths use the same Redis key. Before this, the code read from github_user:${token} but wrote to github_user:${hash}, so cached GitHub profiles were effectively never reused.
additional thing I made just because I wanted to improve
It also makes getOctokitUser() return a consistent profile shape, updates getServerSession() to return a safe fallback GitHub user object instead of an incomplete access-token-only object when the GitHub fetch fails,
also some type warning fixes unrelated to the PR but cool to fix