From f9ab1daa3c5bc7bfa51b1b211ed2e28253738f81 Mon Sep 17 00:00:00 2001 From: shaw Date: Fri, 23 Jan 2026 15:17:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=9D=E5=AD=98=E5=B9=B6=E6=98=BE?= =?UTF-8?q?=E7=A4=BAOAuth=E8=B4=A6=E5=8F=B7=E9=82=AE=E7=AE=B1=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/pkg/oauth/oauth.go | 3 ++- backend/internal/service/oauth_service.go | 13 ++++++++++--- frontend/src/composables/useAccountOAuth.ts | 4 ++++ frontend/src/views/admin/AccountsView.vue | 13 +++++++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/backend/internal/pkg/oauth/oauth.go b/backend/internal/pkg/oauth/oauth.go index 0a607dfb..66c84445 100644 --- a/backend/internal/pkg/oauth/oauth.go +++ b/backend/internal/pkg/oauth/oauth.go @@ -215,5 +215,6 @@ type OrgInfo struct { // AccountInfo represents account info from OAuth response type AccountInfo struct { - UUID string `json:"uuid"` + UUID string `json:"uuid"` + EmailAddress string `json:"email_address"` } diff --git a/backend/internal/service/oauth_service.go b/backend/internal/service/oauth_service.go index 03c3438a..15543080 100644 --- a/backend/internal/service/oauth_service.go +++ b/backend/internal/service/oauth_service.go @@ -122,6 +122,7 @@ type TokenInfo struct { Scope string `json:"scope,omitempty"` OrgUUID string `json:"org_uuid,omitempty"` AccountUUID string `json:"account_uuid,omitempty"` + EmailAddress string `json:"email_address,omitempty"` } // ExchangeCode exchanges authorization code for tokens @@ -252,9 +253,15 @@ func (s *OAuthService) exchangeCodeForToken(ctx context.Context, code, codeVerif tokenInfo.OrgUUID = tokenResp.Organization.UUID log.Printf("[OAuth] Got org_uuid: %s", tokenInfo.OrgUUID) } - if tokenResp.Account != nil && tokenResp.Account.UUID != "" { - tokenInfo.AccountUUID = tokenResp.Account.UUID - log.Printf("[OAuth] Got account_uuid: %s", tokenInfo.AccountUUID) + if tokenResp.Account != nil { + if tokenResp.Account.UUID != "" { + tokenInfo.AccountUUID = tokenResp.Account.UUID + log.Printf("[OAuth] Got account_uuid: %s", tokenInfo.AccountUUID) + } + if tokenResp.Account.EmailAddress != "" { + tokenInfo.EmailAddress = tokenResp.Account.EmailAddress + log.Printf("[OAuth] Got email_address: %s", tokenInfo.EmailAddress) + } } return tokenInfo, nil diff --git a/frontend/src/composables/useAccountOAuth.ts b/frontend/src/composables/useAccountOAuth.ts index e0f77590..bdc6f0f1 100644 --- a/frontend/src/composables/useAccountOAuth.ts +++ b/frontend/src/composables/useAccountOAuth.ts @@ -17,6 +17,7 @@ export interface OAuthState { export interface TokenInfo { org_uuid?: string account_uuid?: string + email_address?: string [key: string]: unknown } @@ -160,6 +161,9 @@ export function useAccountOAuth() { if (tokenInfo.account_uuid) { extra.account_uuid = tokenInfo.account_uuid } + if (tokenInfo.email_address) { + extra.email_address = tokenInfo.email_address + } return Object.keys(extra).length > 0 ? extra : undefined } diff --git a/frontend/src/views/admin/AccountsView.vue b/frontend/src/views/admin/AccountsView.vue index 3b246c5b..222f248d 100644 --- a/frontend/src/views/admin/AccountsView.vue +++ b/frontend/src/views/admin/AccountsView.vue @@ -113,8 +113,17 @@ -