feat: support Alipay open_id when user_id is absent
Build / Running Go tests (push) Waiting to run
Build / Front-end (push) Blocked by required conditions
Build / Back-end (push) Blocked by required conditions
Build / Go-Linter (push) Blocked by required conditions
Build / e2e-test (push) Blocked by required conditions
Build / Create Tag (push) Blocked by required conditions
Build / GitHub Release (push) Blocked by required conditions
Build / Docker Release (push) Blocked by required conditions
golangci-lint / Go-Linter (push) Waiting to run
Crowdin Action / synchronize-with-crowdin (push) Waiting to run
Build / Running Go tests (push) Waiting to run
Build / Front-end (push) Blocked by required conditions
Build / Back-end (push) Blocked by required conditions
Build / Go-Linter (push) Blocked by required conditions
Build / e2e-test (push) Blocked by required conditions
Build / Create Tag (push) Blocked by required conditions
Build / GitHub Release (push) Blocked by required conditions
Build / Docker Release (push) Blocked by required conditions
golangci-lint / Go-Linter (push) Waiting to run
Crowdin Action / synchronize-with-crowdin (push) Waiting to run
This commit is contained in:
+11
-1
@@ -186,6 +186,7 @@ type AlipayUserInfoShareResponse struct {
|
||||
Avatar string `json:"avatar"`
|
||||
NickName string `json:"nick_name"`
|
||||
UserId string `json:"user_id"`
|
||||
OpenId string `json:"open_id"`
|
||||
}
|
||||
|
||||
// GetUserInfo Use access_token to get UserInfo
|
||||
@@ -217,8 +218,17 @@ func (idp *AlipayIdProvider) GetUserInfo(token *oauth2.Token) (*UserInfo, error)
|
||||
return nil, fmt.Errorf("alipay GetUserInfo error: code=%s, msg=%s", resp.Code, resp.Msg)
|
||||
}
|
||||
|
||||
// Alipay apps created after the openid migration no longer return user_id
|
||||
id := resp.UserId
|
||||
if id == "" {
|
||||
id = resp.OpenId
|
||||
}
|
||||
if id == "" {
|
||||
return nil, fmt.Errorf("alipay GetUserInfo error: both user_id and open_id are empty")
|
||||
}
|
||||
|
||||
userInfo := UserInfo{
|
||||
Id: resp.UserId,
|
||||
Id: id,
|
||||
Username: resp.NickName,
|
||||
DisplayName: resp.NickName,
|
||||
AvatarUrl: resp.Avatar,
|
||||
|
||||
Reference in New Issue
Block a user