From 418bcedbbd1538b504c35011f627a628758e987b Mon Sep 17 00:00:00 2001 From: li Date: Fri, 27 Nov 2026 19:19:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(auth):=20=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E9=A6=96=E7=99=BB=E5=BB=BA=E5=8F=B7=E8=A1=A8=E5=8D=95=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E6=8C=89=E5=85=A8=E5=B1=80=E9=82=AE=E7=AE=B1=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=BC=80=E5=85=B3=E9=9A=90=E8=97=8F=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端 createPendingOAuthAccount → RegisterOAuthEmailAccount → VerifyOAuthEmailCode 无条件要求本地邮箱验证码(注释写明有意独立于全局 email_verify_enabled), 发码端点 SendPendingOAuthVerifyCode 同样不看该开关。共享表单 PendingOAuthCreateAccountForm 却在全局开关关闭时隐藏发码入口并把验证码 清空提交,导致微信、OIDC、钉钉首登(及需邀请码时的 Linux DO)在关闭邮箱 验证后一律返回 EMAIL_VERIFY_REQUIRED,用户无法完成建号。 门控源自 aea2950b1:后端只给 Linux DO 加了关闭验证时直接登录的分支, 却把门控加在了所有提供方共用的表单上。去掉该门控,始终显示发码入口 并提交用户填写的验证码;普通注册页 RegisterView 不受影响。 原用例把"关闭时隐藏控件、提交空验证码"写成了预期,改为断言控件仍在、 可发码、提交携带验证码。 Fixes #9103 --- .../auth/PendingOAuthCreateAccountForm.vue | 16 +++++++----- .../PendingOAuthCreateAccountForm.spec.ts | 26 ++++++++++++++----- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue b/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue index 8c97d38b87..bf81e1fc55 100644 --- a/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue +++ b/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue @@ -34,7 +34,12 @@ @error="onTurnstileError" /> -
+ +
-

+

{{ t('auth.codeSentSuccess') }}

-

+

{{ t('auth.verificationCodeHint') }}

{ try { const settings = await getPublicSettings() invitationCodeEnabled.value = settings.invitation_code_enabled === true - emailVerifyEnabled.value = settings.email_verify_enabled !== false turnstileEnabled.value = settings.turnstile_enabled === true turnstileSiteKey.value = settings.turnstile_site_key || '' tencentCaptchaEnabled.value = settings.tencent_captcha_enabled === true @@ -361,7 +364,6 @@ onMounted(async () => { aliyunCaptchaRegion.value = settings.aliyun_captcha_region || 'cn' } catch { invitationCodeEnabled.value = false - emailVerifyEnabled.value = true turnstileEnabled.value = false turnstileSiteKey.value = '' tencentCaptchaEnabled.value = false diff --git a/frontend/src/components/auth/__tests__/PendingOAuthCreateAccountForm.spec.ts b/frontend/src/components/auth/__tests__/PendingOAuthCreateAccountForm.spec.ts index b006a4a3fd..860edda907 100644 --- a/frontend/src/components/auth/__tests__/PendingOAuthCreateAccountForm.spec.ts +++ b/frontend/src/components/auth/__tests__/PendingOAuthCreateAccountForm.spec.ts @@ -169,33 +169,47 @@ describe('PendingOAuthCreateAccountForm', () => { expect(wrapper.text()).toContain('auth.alreadyHaveAccount') }) - it('hides email verification controls when public settings disable email verification', async () => { + // 后端 createPendingOAuthAccount → RegisterOAuthEmailAccount 无条件校验本地邮箱验证码, + // 与全局 email_verify_enabled 无关(#9103)。关闭全局邮箱验证时,表单仍须提供发码入口并提交验证码, + // 否则用户只能拿到 EMAIL_VERIFY_REQUIRED 且无从补救。 + it('keeps email verification controls when public settings disable email verification', async () => { getPublicSettings.mockResolvedValue({ email_verify_enabled: false, turnstile_enabled: false, turnstile_site_key: '' }) + sendPendingOAuthVerifyCode.mockResolvedValue({ countdown: 60 }) const wrapper = mount(PendingOAuthCreateAccountForm, { props: { - testIdPrefix: 'linuxdo', + providerName: 'WeChat', + testIdPrefix: 'wechat', initialEmail: 'prefill@example.com', isSubmitting: false } }) await flushPromises() - await wrapper.get('[data-testid="linuxdo-create-account-password"]').setValue('secret-123') + expect(wrapper.find('[data-testid="wechat-create-account-verify-code"]').exists()).toBe(true) + const sendButton = wrapper.find('[data-testid="wechat-create-account-send-code"]') + expect(sendButton.exists()).toBe(true) + expect(wrapper.text()).toContain('auth.verificationCodeHint') + + await sendButton.trigger('click') + await flushPromises() + expect(sendPendingOAuthVerifyCode).toHaveBeenCalledTimes(1) + expect(sendPendingOAuthVerifyCode.mock.calls[0]?.[0]).toMatchObject({ email: 'prefill@example.com' }) + + await wrapper.get('[data-testid="wechat-create-account-password"]').setValue('secret-123') + await wrapper.get('[data-testid="wechat-create-account-verify-code"]').setValue(' 135790 ') await wrapper.get('form').trigger('submit.prevent') - expect(wrapper.find('[data-testid="linuxdo-create-account-verify-code"]').exists()).toBe(false) - expect(wrapper.find('[data-testid="linuxdo-create-account-send-code"]').exists()).toBe(false) expect(wrapper.emitted('submit')).toEqual([ [ { email: 'prefill@example.com', password: 'secret-123', - verifyCode: '' + verifyCode: '135790' } ] ])