Skip to content

chore: ensure github uids are unique #11826

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

Merged
merged 6 commits into from
Jan 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix was not actually a fix, revert
The test written still passes, will keep looking
  • Loading branch information
Emyrk committed Jan 25, 2024
commit 8077aa69f2e57e3c3aef767ea768ecbd6d2ad48c
13 changes: 1 addition & 12 deletions coderd/userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,18 +604,7 @@ func (api *API) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
return
}

// We intentionally omit the email here. Users should be found through the
// github uuid. If the id is nil, we should never link on the uuid 0.
// This would be a big problem, and should never happen.
if ghUser.GetID() == 0 {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "Github user ID is missing.",
})
return
}

ghid := githubLinkedID(ghUser)
user, link, err := findLinkedUser(ctx, api.Database, ghid)
user, link, err := findLinkedUser(ctx, api.Database, githubLinkedID(ghUser), verifiedEmail.GetEmail())
if err != nil {
logger.Error(ctx, "oauth2: unable to find linked user", slog.F("gh_user", ghUser.Name), slog.Error(err))
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Expand Down