Skip to content

Commit

Permalink
feat: fix bug that GitHub oauth provider shows error if failed to fet…
Browse files Browse the repository at this point in the history
…ch user's email (#3474)

* fix: fix github idp will stop login if it cannot fetch user's email through al restful api

* Update github.go

---------

Co-authored-by: hsluoyz <hsluoyz@qq.com>
  • Loading branch information
dacongda and hsluoyz authored Jan 5, 2025
1 parent e5a2057 commit e27c764
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions idp/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,17 @@ func (idp *GithubIdProvider) GetUserInfo(token *oauth2.Token) (*UserInfo, error)
if err != nil {
return nil, err
}
return nil, fmt.Errorf("%s, %s", errMessage.Message, errMessage.DocumentationUrl)
}

var userEmails []GitHubUserEmailInfo
err = json.Unmarshal(emailBody, &userEmails)
if err != nil {
return nil, err
}
fmt.Printf("GithubIdProvider:GetUserInfo() error, status code = %d, error message = %v\n", respEmail.StatusCode, errMessage)
} else {
var userEmails []GitHubUserEmailInfo
err = json.Unmarshal(emailBody, &userEmails)
if err != nil {
return nil, err
}

githubUserInfo.Email = idp.getEmailFromEmailsResult(userEmails)
githubUserInfo.Email = idp.getEmailFromEmailsResult(userEmails)
}
}

userInfo := UserInfo{
Expand Down

0 comments on commit e27c764

Please sign in to comment.