Skip to content

Commit

Permalink
Check return OAuth ID reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson committed Jan 7, 2021
1 parent c393e72 commit e23f5f0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions http/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ func (s *Server) handleOAuthGitHubCallback(w http.ResponseWriter, r *http.Reques
)))

// Fetch user information for the currently authenticated user.
// Require that we at least receive a user ID from GitHub.
u, _, err := client.Users.Get(r.Context(), "")
if err != nil {
Error(w, r, fmt.Errorf("cannot fetch github user: %s", err))
return
} else if u.ID == nil {
Error(w, r, fmt.Errorf("user ID not returned by GitHub, cannot authenticate user"))
return
}

// Email is not necessarily available for all accounts. If it is, store it
Expand Down

0 comments on commit e23f5f0

Please sign in to comment.