Wyślij e -mail sgmail
router.post(
'/send-mail',
AuthController.sendMail
)
async sendMail(req, res, next){
try{
let otp = generateOtp();
const msg = {
to: req.body.email,
from: '[email protected]', // Change to your verified sender
subject: 'Eye 1-1: Verify Your Login',
text: 'Please enter the following OTP to verify your login : ' + otp,
html: '<strong>Please enter the following OTP to verify your login :' + otp + ' </strong>',
}
//Send Email Here
sgMail
.send(msg)
.then(() => {
console.log('Email sent');
return res.success({
}, "Email Send Successfully"
);
// const userJson = user.toJSON();
// ['password', 'authTokenIssuedAt', 'otp', 'emailToken', '__v'].forEach(key => delete userJson[key]);
// userJson.isDefaultLocation = false;
// return res.success({
// "language": req.headers['accept-language'],
// token,
// user: userJson,
// }, "Registration Completed"
// );
})}
catch (err) {
console.log(err);
return next(err)
}
}
Angry Albatross