Found an uncaught error
This commit is contained in:
+28
-16
@@ -111,24 +111,36 @@ const sendValidationEmail = async (email, username, token) => {
|
|||||||
const addr = `${process.env.WEB_PROTOCOL}://${process.env.WEB_ADDRESS}/api/accounts/validation?username=${username}&token=${token}`;
|
const addr = `${process.env.WEB_PROTOCOL}://${process.env.WEB_ADDRESS}/api/accounts/validation?username=${username}&token=${token}`;
|
||||||
const msg = `Hello! Please visit the following address to validate your account: ${addr}`;
|
const msg = `Hello! Please visit the following address to validate your account: ${addr}`;
|
||||||
|
|
||||||
|
let transporter, info;
|
||||||
|
|
||||||
//what exactly is a transport?
|
//what exactly is a transport?
|
||||||
let transporter = nodemailer.createTransport({
|
try {
|
||||||
host: process.env.MAIL_SMTP,
|
transporter = nodemailer.createTransport({
|
||||||
port: 465,
|
host: process.env.MAIL_SMTP,
|
||||||
secure: true,
|
port: 465,
|
||||||
auth: {
|
secure: true,
|
||||||
user: process.env.MAIL_USERNAME,
|
auth: {
|
||||||
pass: process.env.MAIL_PASSWORD
|
user: process.env.MAIL_USERNAME,
|
||||||
},
|
pass: process.env.MAIL_PASSWORD
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
return `failed to create transport: ${e}`;
|
||||||
|
}
|
||||||
|
|
||||||
// send mail with defined transport object
|
// send mail with defined transport object
|
||||||
let info = await transporter.sendMail({
|
try {
|
||||||
from: `signup@${process.env.WEB_ADDRESS}`, //WARNING: google overwrites this
|
info = await transporter.sendMail({
|
||||||
to: email,
|
from: `signup@${process.env.WEB_ADDRESS}`, //WARNING: google overwrites this
|
||||||
subject: 'Email Validation',
|
to: email,
|
||||||
text: msg
|
subject: 'Email Validation',
|
||||||
});
|
text: msg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
return `failed to send mail ${e}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (info.accepted[0] != email) {
|
if (info.accepted[0] != email) {
|
||||||
return 'validation email failed';
|
return 'validation email failed';
|
||||||
|
|||||||
Reference in New Issue
Block a user