🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(auth): isolate OAuth from email validation and align success description (#20545)
Innei4ce7654bcf7f
diff --git a/src/features/Auth/OAuthCallback/Success.tsx b/src/features/Auth/OAuthCallback/Success.tsxindex a80f3a35de0..45feaa273a8 100644--- a/src/features/Auth/OAuthCallback/Success.tsx+++ b/src/features/Auth/OAuthCallback/Success.tsx@@ -50,7 +50,7 @@ const SuccessPage = memo(() => {icon={<FluentEmoji emoji={'✅'} size={96} type={'anim'} />}status="success"subTitle={- <Text fontSize={16} type="secondary">+ <Text align="left" as="span" fontSize={16} style={{ display: 'block' }} type="secondary">{provider? t('success.subTitleWithCountdown', {countdown,diff --git a/src/features/Auth/SignIn/SignInEmailStep.tsx b/src/features/Auth/SignIn/SignInEmailStep.tsxindex f9cf551a8d8..d339625e83b 100644--- a/src/features/Auth/SignIn/SignInEmailStep.tsx+++ b/src/features/Auth/SignIn/SignInEmailStep.tsx@@ -115,6 +115,7 @@ export const SignInEmailStep = ({const button = (<Buttonblock+ htmlType="button"icon={<Icon icon={AuthIcons(provider, 18)} />}key={provider}loading={socialLoading === provider}@@ -158,6 +159,7 @@ export const SignInEmailStep = ({<Form.Fieldname="email"style={{ gap: 0, paddingBlock: '0 24px' }}+ validateOn="submit"validate={(value: string) => {if (!value) return t('betterAuth.errors.emailRequired');const trimmedValue = value.trim();diff --git a/src/features/AuthShell/AuthAgreement.test.tsx b/src/features/AuthShell/AuthAgreement.test.tsxindex 218ff91fd92..8f1920483cc 100644--- a/src/features/AuthShell/AuthAgreement.test.tsx+++ b/src/features/AuthShell/AuthAgreement.test.tsx@@ -1,6 +1,6 @@import * as BaseUI from '@lobehub/ui/base-ui';import { useForm } from '@lobehub/ui/base-ui/form';-import { act, fireEvent, render, renderHook, screen } from '@testing-library/react';+import { act, fireEvent, render, renderHook, screen, waitFor } from '@testing-library/react';import type { ReactElement } from 'react';import { afterEach, describe, expect, it, vi } from 'vitest';@@ -59,6 +59,56 @@ describe('AuthAgreement', () => {});describe('SignInEmailStep', () => {+ it.each(['', 'invalid@', '[email protected]'])(+ 'should not validate or submit email %j when choosing OAuth',+ async (email) => {+ const onSubmit = vi.fn();+ const onSocialSignIn = vi.fn();+ const TestSignInEmailStep = () => {+ const form = useForm({ initialValues: { email }, onSubmit });++ return (+ <SignInEmailStep+ agreementChecked+ serverConfigInit+ continueWithAgreement={(next) => next()}+ form={form}+ isSocialOnly={false}+ loading={false}+ oAuthSSOProviders={['google']}+ setAgreementChecked={vi.fn()}+ socialLoading={null}+ onGoToSignup={vi.fn()}+ onResetEmail={vi.fn()}+ onSetPassword={vi.fn()}+ onSocialSignIn={onSocialSignIn}+ />+ );+ };++ render(<TestSignInEmailStep />);+ const input = screen.getByRole('textbox');+ await act(async () => {+ fireEvent.blur(input);+ fireEvent.click(screen.getByRole('button', { name: /Google/ }));+ });++ expect(onSocialSignIn).toHaveBeenCalledExactlyOnceWith('google');+ expect(onSubmit).not.toHaveBeenCalled();+ expect(input).not.toHaveAttribute('aria-invalid', 'true');++ fireEvent.click(screen.getByRole('button', { name: 'betterAuth.signin.nextStep' }));+ await waitFor(() => {+ if (email === '[email protected]') {+ expect(onSubmit).toHaveBeenCalledExactlyOnceWith({ email });+ } else {+ expect(input).toHaveAttribute('aria-invalid', 'true');+ expect(onSubmit).not.toHaveBeenCalled();+ }+ });+ },+ );+it('should confirm the agreement before social sign-in', async () => {let confirmAgreement: (() => Promise<void>) | (() => void) | undefined;vi.spyOn(BaseUI, 'confirmModal').mockImplementation(({ onOk }) => {