mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-07 02:20:28 +08:00
feat(lark): support enterprise_email field as email fallback (#4128)
This commit is contained in:
11
idp/lark.go
11
idp/lark.go
@@ -135,6 +135,7 @@ func (idp *LarkIdProvider) GetToken(code string) (*oauth2.Token, error) {
|
|||||||
"open_id": "ou-caecc734c2e3328a62489fe0648c4b98779515d3",
|
"open_id": "ou-caecc734c2e3328a62489fe0648c4b98779515d3",
|
||||||
"union_id": "on-d89jhsdhjsajkda7828enjdj328ydhhw3u43yjhdj",
|
"union_id": "on-d89jhsdhjsajkda7828enjdj328ydhhw3u43yjhdj",
|
||||||
"email": "zhangsan@feishu.cn",
|
"email": "zhangsan@feishu.cn",
|
||||||
|
"enterprise_email": "zhangsan@company.com",
|
||||||
"user_id": "5d9bdxxx",
|
"user_id": "5d9bdxxx",
|
||||||
"mobile": "+86130002883xx",
|
"mobile": "+86130002883xx",
|
||||||
"tenant_key": "736588c92lxf175d",
|
"tenant_key": "736588c92lxf175d",
|
||||||
@@ -160,6 +161,7 @@ type LarkUserInfo struct {
|
|||||||
OpenId string `json:"open_id"`
|
OpenId string `json:"open_id"`
|
||||||
UnionId string `json:"union_id"`
|
UnionId string `json:"union_id"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
|
EnterpriseEmail string `json:"enterprise_email"`
|
||||||
UserId string `json:"user_id"`
|
UserId string `json:"user_id"`
|
||||||
Mobile string `json:"mobile"`
|
Mobile string `json:"mobile"`
|
||||||
TenantKey string `json:"tenant_key"`
|
TenantKey string `json:"tenant_key"`
|
||||||
@@ -168,7 +170,6 @@ type LarkUserInfo struct {
|
|||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserInfo use LarkAccessToken gotten before return LinkedInUserInf
|
|
||||||
// GetUserInfo use LarkAccessToken gotten before return LinkedInUserInfo
|
// GetUserInfo use LarkAccessToken gotten before return LinkedInUserInfo
|
||||||
// get more detail via: https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin?context=linkedin/consumer/context
|
// get more detail via: https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin?context=linkedin/consumer/context
|
||||||
func (idp *LarkIdProvider) GetUserInfo(token *oauth2.Token) (*UserInfo, error) {
|
func (idp *LarkIdProvider) GetUserInfo(token *oauth2.Token) (*UserInfo, error) {
|
||||||
@@ -207,6 +208,12 @@ func (idp *LarkIdProvider) GetUserInfo(token *oauth2.Token) (*UserInfo, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use enterprise_email as fallback when email is empty
|
||||||
|
email := larkUserInfo.Data.Email
|
||||||
|
if email == "" {
|
||||||
|
email = larkUserInfo.Data.EnterpriseEmail
|
||||||
|
}
|
||||||
|
|
||||||
var phoneNumber string
|
var phoneNumber string
|
||||||
var countryCode string
|
var countryCode string
|
||||||
if len(larkUserInfo.Data.Mobile) != 0 {
|
if len(larkUserInfo.Data.Mobile) != 0 {
|
||||||
@@ -222,7 +229,7 @@ func (idp *LarkIdProvider) GetUserInfo(token *oauth2.Token) (*UserInfo, error) {
|
|||||||
Id: larkUserInfo.Data.OpenId,
|
Id: larkUserInfo.Data.OpenId,
|
||||||
DisplayName: larkUserInfo.Data.Name,
|
DisplayName: larkUserInfo.Data.Name,
|
||||||
Username: larkUserInfo.Data.UserId,
|
Username: larkUserInfo.Data.UserId,
|
||||||
Email: larkUserInfo.Data.Email,
|
Email: email,
|
||||||
AvatarUrl: larkUserInfo.Data.AvatarUrl,
|
AvatarUrl: larkUserInfo.Data.AvatarUrl,
|
||||||
Phone: phoneNumber,
|
Phone: phoneNumber,
|
||||||
CountryCode: countryCode,
|
CountryCode: countryCode,
|
||||||
|
Reference in New Issue
Block a user