Allows very simple mail adapters
- Fix nasty bug when updating users email and sending verification
This commit is contained in:
@@ -1,7 +1,23 @@
|
||||
|
||||
/*
|
||||
Mail Adapter prototype
|
||||
A MailAdapter should implement at least sendMail()
|
||||
*/
|
||||
export class MailAdapter {
|
||||
sendVerificationEmail(options) {}
|
||||
sendPasswordResetEmail(options) {}
|
||||
/*
|
||||
* A method for sending mail
|
||||
* @param options would have the parameters
|
||||
* - to: the recipient
|
||||
* - text: the raw text of the message
|
||||
* - subject: the subject of the email
|
||||
*/
|
||||
sendMail(options) {}
|
||||
|
||||
/* You can implement those methods if you want
|
||||
* to provide HTML templates etc...
|
||||
*/
|
||||
// sendVerificationEmail({ link, appName, user }) {}
|
||||
// sendPasswordResetEmail({ link, appName, user }) {}
|
||||
}
|
||||
|
||||
export default MailAdapter;
|
||||
|
||||
@@ -25,31 +25,6 @@ let SimpleMailgunAdapter = mailgunOptions => {
|
||||
}
|
||||
|
||||
return Object.freeze({
|
||||
sendVerificationEmail: ({ link, user, appName, }) => {
|
||||
let verifyMessage =
|
||||
"Hi,\n\n" +
|
||||
"You are being asked to confirm the e-mail address " + user.email + " with " + appName + "\n\n" +
|
||||
"" +
|
||||
"Click here to confirm it:\n" + link;
|
||||
return sendMail({
|
||||
to:user.email,
|
||||
subject: 'Please verify your e-mail for ' + appName,
|
||||
text: verifyMessage
|
||||
});
|
||||
},
|
||||
|
||||
sendPasswordResetEmail: ({link,user, appName}) => {
|
||||
let message =
|
||||
"Hi,\n\n" +
|
||||
"You requested to reset your password for " + appName + ".\n\n" +
|
||||
"" +
|
||||
"Click here to reset it:\n" + link;
|
||||
return sendMail({
|
||||
to:user.email,
|
||||
subject: 'Password Reset for ' + appName,
|
||||
text: message
|
||||
});
|
||||
},
|
||||
sendMail: sendMail
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user