Closed rupamking1 closed 3 years ago
The source is a node js a server that controls the process of sending Emails, Here is a complete snippet of the Get Request process for your reference.
router.get("/auth/:mail", async (req, res)=>{
try {
const {mail} = req.params;
let {CompanyName} = req.query;
console.log(CompanyName)
if(CompanyName == undefined || CompanyName.length <= 0){
CompanyName = "";
}
if(validateEmail(mail) && mail.length > 0){
let OTP = generateOtp();
while(OTP in previous){
OTP = generateOtp();
}
previous.push(OTP);
if(flag){
mailData = spawn('python', ['mailer.py', mail, OTP, CompanyName, orgMail, orgPass])
} else {
mailData = spawn('python', ['mailer.py', mail, OTP, CompanyName])
}
mailData.stdout.on('data', async (data)=>{
const readerData = await data.toString();
console.log(data.toString());
if(readerData.includes('error')){
res.json({
status: 404,
mail: mail,
success: false,
message: "Unable to send mail"
})
} else {
res.json({
status : 200,
mail: mail,
OTP: OTP,
success: true
});
}
})
} else {
res.json({
status : 404,
mail: mail,
error: "The mail id is not valid",
success: false
});
}
} catch (error) {
console.log(error.message);
res.json({
status : 404,
error: "Server error",
success : false
});
}
})
Thanks bro
Please share source code of- https://app-authenticator.herokuapp.com/