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.
This commit is contained in:
Shane Kilkelly 2017-03-27 16:17:38 +01:00
parent 30c5bbfdfc
commit 69b9b308d4
2 changed files with 4 additions and 3 deletions

View file

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

View file

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