From 69b9b308d4c929cfa133e12d0d827dd1b800c0ce Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Mon, 27 Mar 2017 16:17:38 +0100 Subject: [PATCH] If sending email fails, return a generic error. This prevents us from leaking juicy details of our aws/ses setup via the password-reset form. --- services/web/app/coffee/Features/Email/EmailSender.coffee | 2 +- .../web/test/UnitTests/coffee/Email/EmailSenderTests.coffee | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/services/web/app/coffee/Features/Email/EmailSender.coffee b/services/web/app/coffee/Features/Email/EmailSender.coffee index 69574c8276..009d24e182 100644 --- a/services/web/app/coffee/Features/Email/EmailSender.coffee +++ b/services/web/app/coffee/Features/Email/EmailSender.coffee @@ -74,4 +74,4 @@ module.exports = logger.err err:err, "error sending message" else logger.log "Message sent to #{options.to}" - callback(err) + callback(new Error('Cannot send email')) diff --git a/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee b/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee index beba91fcb3..bdc2a44811 100644 --- a/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee +++ b/services/web/test/UnitTests/coffee/Email/EmailSenderTests.coffee @@ -58,10 +58,11 @@ describe "EmailSender", -> args.subject.should.equal @opts.subject done() - it "should return the error", (done)-> + it "should return a non-specific error", (done)-> @sesClient.sendMail.callsArgWith(1, "error") @sender.sendEmail {}, (err)=> - err.should.equal "error" + err.should.exist + err.toString().should.equal 'Error: Cannot send email' done()