-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
Sorry for leaving this hanging for so long :(
Second, the
If that's unclear please poke 🙈 |
Is it clear what I'm looking for re: the mail transport stuff? The end goal is that server hosts can do something like new ApiV1(uwaveInstance, {
mailTransport: {
// options for `nodemailer.createTransport(options)`
}
}) and import sendgridTransport from 'nodemailer-sendgrid-transport'
new ApiV1(uwaveInstance, {
mailTransport: sendgridTransport({
auth: { api_key: 'sendgrid api key' }
})
}) and have the reset password mail be sent over a Nodemailer transport with the given configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for continuing to work on this 🙇♀️ I'll try to be a bit quicker at reviewing as well :') I have two comments for now.
src/email.js
Outdated
} | ||
|
||
// create reusable transporter object using the default SMTP transport | ||
const transporter = mailTransport.createTransport(smtpOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom nodemailer transports work by passing the transport to nodemailer.createTransport
. So this line should be nodemailer.createTransport(options.mailTransport || smtpOptions)
, in order to use the custom transport if the option is specified, or else the default smtp transport.
src/email.js
Outdated
}; | ||
|
||
// send mail with defined transport object | ||
if (transporter.sendMail(mailOptions)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sendMail
returns a promise, you need to wait for the promise to resolve before you can use the result. Here it'll always return true
because the if
will cast a Promise object to true
, even if it represents a failed operation.
Here we'd want to return the Promise object if something failed, so that the web API will return an error response. If it all succeeded we want to return the Promise object but with the contents redacted (since nodemailer returns a bunch of information about the server it sends mail to or whatever). The simplest way to do that would be to:
return transporter.sendMail(mailOptions)
.then(() => ({})) // ← confusing but () => ({}) is a function that returns an empty object
Which would return a successful Promise object with the success value {}
(empty object) if the email was sent, or a failed Promise object if something went wrong.
btw, @goto-bus-stop still need an html page for the reset password form. |
Rebased&merged in f710364, thanks for working on this! 🎉 |
No description provided.