From 2ce27a2b9b14afea8e5267c787432c3974213912 Mon Sep 17 00:00:00 2001 From: Zack Schuster Date: Mon, 25 May 2020 23:34:54 -0700 Subject: [PATCH] smtp/smtp: error on `password` without `user` --- smtp/smtp.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/smtp/smtp.ts b/smtp/smtp.ts index 17f9da2..21d0428 100644 --- a/smtp/smtp.ts +++ b/smtp/smtp.ts @@ -167,6 +167,10 @@ export class SMTPConnection extends EventEmitter { this.port = port || (ssl ? SMTP_SSL_PORT : tls ? SMTP_TLS_PORT : SMTP_PORT); this.loggedin = user && password ? false : true; + if (!user && (password?.length ?? 0) > 0) { + throw new Error('`password` cannot be set without `user`'); + } + // keep these strings hidden when quicky debugging/logging this.user = () => user as string; this.password = () => password as string;