chore(server): remove enable flag in mail config (#11680)

close #11625
This commit is contained in:
forehalo
2025-04-15 09:18:09 +00:00
parent b249939093
commit 7257f1b55b
15 changed files with 55 additions and 70 deletions
@@ -11,7 +11,7 @@ import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hoo
import { AuthService, CaptchaService } from '@affine/core/modules/cloud';
import type { AuthSessionStatus } from '@affine/core/modules/cloud/entities/session';
import { Unreachable } from '@affine/env/constant';
import type { UserFriendlyError } from '@affine/error';
import { UserFriendlyError } from '@affine/error';
import { Trans, useI18n } from '@affine/i18n';
import { useLiveData, useService } from '@toeverything/infra';
import {
@@ -95,8 +95,10 @@ export const SignInWithEmailStep = ({
);
} catch (err) {
console.error(err);
const error = UserFriendlyError.fromAny(err);
notify.error({
title: 'Failed to send email, please try again.',
title: 'Failed to sign in',
message: t[`error.${error.name}`](error.data),
});
}
setIsSending(false);
@@ -109,6 +111,7 @@ export const SignInWithEmailStep = ({
needCaptcha,
state.redirectUrl,
verifyToken,
t,
]);
useEffect(() => {
@@ -93,46 +93,22 @@ export const SignInStep = ({
setIsMutating(true);
try {
const { hasPassword, registered, magicLink } =
await authService.checkUserByEmail(email);
const { hasPassword } = await authService.checkUserByEmail(email);
if (registered) {
// provider password sign-in if user has by default
// If with payment, onl support email sign in to avoid redirect to affine app
if (hasPassword) {
changeState(prev => ({
...prev,
email,
step: 'signInWithPassword',
hasPassword: true,
}));
} else {
if (magicLink) {
changeState(prev => ({
...prev,
email,
step: 'signInWithEmail',
hasPassword: false,
}));
} else {
notify.error({
title: 'Failed to send email. Please contact the administrator.',
});
}
}
if (hasPassword) {
changeState(prev => ({
...prev,
email,
step: 'signInWithPassword',
hasPassword: true,
}));
} else {
if (magicLink) {
changeState(prev => ({
...prev,
email,
step: 'signInWithEmail',
hasPassword: false,
}));
} else {
notify.error({
title: 'Failed to send email. Please contact the administrator.',
});
}
changeState(prev => ({
...prev,
email,
step: 'signInWithEmail',
hasPassword: false,
}));
}
} catch (err: any) {
console.error(err);