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

View File

@@ -92,10 +92,6 @@
}
},
"mailer": {
"enabled": {
"type": "Boolean",
"desc": "Whether enabled mail service."
},
"SMTP.host": {
"type": "String",
"desc": "Host of the email server (e.g. smtp.gmail.com)",

View File

@@ -76,7 +76,6 @@ export const KNOWN_CONFIG_GROUPS = [
name: 'Notification',
module: 'mailer',
fields: [
'enabled',
'SMTP.host',
'SMTP.port',
'SMTP.username',

View File

@@ -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(() => {

View File

@@ -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);

View File

@@ -7690,6 +7690,10 @@ export function useAFFiNEI18N(): {
["error.HTTP_REQUEST_ERROR"](options: {
readonly message: string;
}): string;
/**
* `Email service is not configured.`
*/
["error.EMAIL_SERVICE_NOT_CONFIGURED"](): string;
/**
* `Query is too long, max length is {{max}}.`
*/

View File

@@ -1923,6 +1923,7 @@
"error.BAD_REQUEST": "Bad request.",
"error.GRAPHQL_BAD_REQUEST": "GraphQL bad request, code: {{code}}, {{message}}",
"error.HTTP_REQUEST_ERROR": "HTTP request error, message: {{message}}",
"error.EMAIL_SERVICE_NOT_CONFIGURED": "Email service is not configured.",
"error.QUERY_TOO_LONG": "Query is too long, max length is {{max}}.",
"error.VALIDATION_ERROR": "Validation error, errors: {{errors}}",
"error.USER_NOT_FOUND": "User not found.",