From e738c42bd84dec99782ac1e173237dc0f8977b5a Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 23 Feb 2022 23:58:17 +0800 Subject: [PATCH] fix: facebook login exceptions (#508) * Fix the exception caused by "Username" being empty when logging in with facebook * fix: facebook login missing "Username" exception --- idp/facebook.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/idp/facebook.go b/idp/facebook.go index bd1bd0aa..07d3ec41 100644 --- a/idp/facebook.go +++ b/idp/facebook.go @@ -122,9 +122,9 @@ func (idp *FacebookIdProvider) GetToken(code string) (*oauth2.Token, error) { //} type FacebookUserInfo struct { - Id string `json:"id"` // The app user's App-Scoped User ID. This ID is unique to the app and cannot be used by other apps. - Name string `json:"name"` // The person's full name. - NameFormat string `json:"name_format"` // The person's name formatted to correctly handle Chinese, Japanese, or Korean ordering. + Id string `json:"id"` // The app user's App-Scoped User ID. This ID is unique to the app and cannot be used by other apps. + Name string `json:"name"` // The person's full name. + NameFormat string `json:"name_format"` // The person's name formatted to correctly handle Chinese, Japanese, or Korean ordering. Picture struct { // The person's profile picture. Data struct { // This struct is different as https://developers.facebook.com/docs/graph-api/reference/user/picture/ Height int `json:"height"` @@ -164,6 +164,7 @@ func (idp *FacebookIdProvider) GetUserInfo(token *oauth2.Token) (*UserInfo, erro userInfo := UserInfo{ Id: facebookUserInfo.Id, + Username: facebookUserInfo.Name, DisplayName: facebookUserInfo.Name, Email: facebookUserInfo.Email, AvatarUrl: facebookUserInfo.Picture.Data.Url,