mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 21:06:22 +08:00
fix: allow empty mailer password (#6066)
fix #6046 smtp relay may allow empty password, although this is usually not safe
This commit is contained in:
@@ -8,7 +8,7 @@ import { MAILER } from './mailer';
|
|||||||
@OptionalModule({
|
@OptionalModule({
|
||||||
providers: [MAILER],
|
providers: [MAILER],
|
||||||
exports: [MAILER],
|
exports: [MAILER],
|
||||||
requires: ['mailer.auth.user', 'mailer.auth.pass'],
|
requires: ['mailer.auth.user'],
|
||||||
})
|
})
|
||||||
class MailerModule {}
|
class MailerModule {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FactoryProvider } from '@nestjs/common';
|
import { FactoryProvider, Logger } from '@nestjs/common';
|
||||||
import { createTransport, Transporter } from 'nodemailer';
|
import { createTransport, Transporter } from 'nodemailer';
|
||||||
import SMTPTransport from 'nodemailer/lib/smtp-transport';
|
import SMTPTransport from 'nodemailer/lib/smtp-transport';
|
||||||
|
|
||||||
@@ -15,7 +15,19 @@ export const MAILER: FactoryProvider<
|
|||||||
> = {
|
> = {
|
||||||
provide: MAILER_SERVICE,
|
provide: MAILER_SERVICE,
|
||||||
useFactory: (config: Config) => {
|
useFactory: (config: Config) => {
|
||||||
return config.mailer ? createTransport(config.mailer) : undefined;
|
if (config.mailer) {
|
||||||
|
const logger = new Logger('Mailer');
|
||||||
|
const auth = config.mailer.auth;
|
||||||
|
if (auth && auth.user && !('pass' in auth)) {
|
||||||
|
logger.warn(
|
||||||
|
'Mailer service has not configured password, please make sure your mailer service allow empty password.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return createTransport(config.mailer);
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
inject: [Config],
|
inject: [Config],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user