mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
@@ -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)",
|
||||
|
||||
@@ -76,7 +76,6 @@ export const KNOWN_CONFIG_GROUPS = [
|
||||
name: 'Notification',
|
||||
module: 'mailer',
|
||||
fields: [
|
||||
'enabled',
|
||||
'SMTP.host',
|
||||
'SMTP.port',
|
||||
'SMTP.username',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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}}.`
|
||||
*/
|
||||
|
||||
@@ -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.",
|
||||
|
||||
Reference in New Issue
Block a user