Sync GitHub OAuth user name to Grafana if it's set (#45438)

This commit is contained in:
Xiangkun Liu 2022-03-09 00:11:51 +08:00 committed by GitHub
parent db5f480a8f
commit 5fc5de8d5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,6 +182,7 @@ func (s *SocialGithub) UserInfo(client *http.Client, token *oauth2.Token) (*Basi
Id int `json:"id"`
Login string `json:"login"`
Email string `json:"email"`
Name string `json:"name"`
}
response, err := s.httpGet(client, s.apiUrl)
@ -208,6 +209,9 @@ func (s *SocialGithub) UserInfo(client *http.Client, token *oauth2.Token) (*Basi
Email: data.Email,
Groups: teams,
}
if data.Name != "" {
userInfo.Name = data.Name
}
organizationsUrl := fmt.Sprintf(s.apiUrl + "/orgs")