From 2c5443df9b8700e14c9c0350f97316e85cf0860a Mon Sep 17 00:00:00 2001 From: liangjies <1139629972@qq.com> Date: Wed, 17 Jul 2024 08:17:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20github=E7=BB=91=E5=AE=9A=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app/assets/locale.json | 6 ++++-- internal/app/dao/social.go | 12 ++++++++++++ internal/auth/service/github.go | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/internal/app/assets/locale.json b/internal/app/assets/locale.json index 6e34a4e..d081707 100644 --- a/internal/app/assets/locale.json +++ b/internal/app/assets/locale.json @@ -37,7 +37,8 @@ "AddressAlreadyLinkedEmail": "The wallet address has already been linked to Email. Please do not repeat the operation.", "EmailAlreadyLinked": "The email has already been linked to another address!", "GithubAlreadyLinked": "Github has been linked to another wallet address!", - "AddressAlreadyLinkedGithub": "The wallet address has already been linked to Github. Please do not repeat the operation." + "AddressAlreadyLinkedGithub": "The wallet address has already been linked to Github. Please do not repeat the operation.", + "FailedObtainGithubInfo": "Failed to obtain Github information!" }, "zh-CN": { "OperationSuccess": "操作成功!", @@ -77,6 +78,7 @@ "AddressAlreadyLinkedEmail": "钱包地址已绑定邮箱,请勿重复操作", "EmailAlreadyLinked": "邮箱已绑定其他钱包地址", "GithubAlreadyLinked": "Github 已绑定其他钱包地址", - "AddressAlreadyLinkedGithub": "钱包地址已绑定Github,请勿重复操作" + "AddressAlreadyLinkedGithub": "钱包地址已绑定Github,请勿重复操作", + "FailedObtainGithubInfo": "绑定 Github 信息失败!" } } \ No newline at end of file diff --git a/internal/app/dao/social.go b/internal/app/dao/social.go index 6ed926e..e9c83e2 100644 --- a/internal/app/dao/social.go +++ b/internal/app/dao/social.go @@ -28,6 +28,9 @@ func (d *Dao) WechatIsBinding(fromUserName string) (string, bool, error) { } return "", false, err } + if address == "" { + return "", false, nil + } return address, true, nil } @@ -113,6 +116,9 @@ func (d *Dao) DiscordIsBinding(discordID string) (string, bool, error) { } return "", false, err } + if address == "" { + return "", false, nil + } return address, true, nil } @@ -126,6 +132,9 @@ func (d *Dao) EmailIsBinding(email string) (string, bool, error) { } return "", false, err } + if address == "" { + return "", false, nil + } return address, true, nil } @@ -202,6 +211,9 @@ func (d *Dao) GithubIsBinding(githubID string) (string, bool, error) { } return "", false, err } + if address == "" { + return "", false, nil + } return address, true, nil } diff --git a/internal/auth/service/github.go b/internal/auth/service/github.go index e236c99..3a9a827 100644 --- a/internal/auth/service/github.go +++ b/internal/auth/service/github.go @@ -41,6 +41,6 @@ func (s *Service) GithubCallback(code, callback string) (id, username string, er return } id = gjson.Get(res.String(), "id").String() - username = gjson.Get(res.String(), "name").String() + username = gjson.Get(res.String(), "login").String() return id, username, err }