There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): prevent frequent sign-in (#6339)
fundonef354f164379
diff --git a/packages/frontend/core/src/components/affine/auth/sign-in-with-password.tsx b/packages/frontend/core/src/components/affine/auth/sign-in-with-password.tsxindex e5e6ff8515..b6765d2cf9 100644--- a/packages/frontend/core/src/components/affine/auth/sign-in-with-password.tsx+++ b/packages/frontend/core/src/components/affine/auth/sign-in-with-password.tsx@@ -35,20 +35,26 @@ export const SignInWithPassword: FC<AuthPanelProps> = ({isMutating: sendingEmail,} = useAuth();const [verifyToken, challenge] = useCaptcha();+ const [isLoading, setIsLoading] = useState(false);const onSignIn = useAsyncCallback(async () => {+ if (isLoading) return;+ setIsLoading(true);+const res = await signInCloud('credentials', {email,password,}).catch(console.error);- if (!res?.ok) {- return setPasswordError(true);+ if (res?.ok) {+ await reload();+ onSignedIn?.();+ } else {+ setPasswordError(true);}- await reload();- onSignedIn?.();- }, [email, password, onSignedIn, reload]);+ setIsLoading(false);+ }, [email, password, isLoading, onSignedIn, reload]);const sendMagicLink = useAsyncCallback(async () => {if (allowSendEmail && verifyToken && !sendingEmail) {@@ -134,6 +140,7 @@ export const SignInWithPassword: FC<AuthPanelProps> = ({type="primary"size="extraLarge"style={{ width: '100%' }}+ disabled={isLoading}onClick={onSignIn}>{t['com.affine.auth.sign.in']()}