diff --git a/frontend/src/views/auth/WechatCallbackView.vue b/frontend/src/views/auth/WechatCallbackView.vue index edc72d9d..e4dd6301 100644 --- a/frontend/src/views/auth/WechatCallbackView.vue +++ b/frontend/src/views/auth/WechatCallbackView.vue @@ -116,11 +116,16 @@ {{ t('auth.alreadyHaveAccount') }}
- Sign in to an existing account, then bind this WeChat identity to it. + {{ + hasCurrentAuthToken + ? 'Bind this WeChat identity to the account currently signed in on this browser.' + : 'Sign in to an existing account, then bind this WeChat identity to it.' + }}
- {{ t('auth.signIn') }} + {{ hasCurrentAuthToken ? 'Bind current account' : t('auth.signIn') }} @@ -353,6 +358,7 @@ const bindSuccessMessage = t('profile.authBindings.bindSuccess') const providerName = 'WeChat' const needsCreateAccount = computed(() => pendingAccountAction.value === 'create_account') const needsBindLogin = computed(() => pendingAccountAction.value === 'bind_login') +const hasCurrentAuthToken = computed(() => Boolean(getAuthToken())) type PendingWeChatCompletion = PendingOAuthExchangeResponse & { step?: string diff --git a/frontend/src/views/auth/__tests__/WechatCallbackView.spec.ts b/frontend/src/views/auth/__tests__/WechatCallbackView.spec.ts index 80d8b23b..c49d0243 100644 --- a/frontend/src/views/auth/__tests__/WechatCallbackView.spec.ts +++ b/frontend/src/views/auth/__tests__/WechatCallbackView.spec.ts @@ -345,6 +345,35 @@ describe('WechatCallbackView', () => { expect(replaceMock.mock.calls[0]?.[0]).toContain('mode%3Dopen') }) + it('binds directly to the current signed-in account during invitation flow', async () => { + exchangePendingOAuthCompletionMock.mockResolvedValue({ + error: 'invitation_required', + redirect: '/usage', + }) + getAuthTokenMock.mockReturnValue('current-auth-token') + + const wrapper = mount(WechatCallbackView, { + global: { + stubs: { + AuthLayout: { template: '