Push Emails added

This commit is contained in:
yashraj verma 2021-05-12 17:18:25 +05:30 committed by GitHub
parent 77f96f0eac
commit f1c5ba4b2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 8 deletions

View File

@ -79,6 +79,9 @@ module.exports.postSignin = async (req, res, next) => {
}
};
// Phone verification Starts.
// -----------------------------------------------------------------------------------------------
module.exports.sendOTP = (req, res, next) => {
//uNNYosMopvvCW9RTR1tRWJmYC test
//llVKD53ve6QRpbCKOHzWBADaS live
@ -111,8 +114,8 @@ module.exports.sendOTP = (req, res, next) => {
module.exports.getOTP = (req, res, next) => {
try {
const { id, token } = req.body;
messagebird.verify.verify(id, token, function (err, response) {
const { id, otp } = req.body;
messagebird.verify.verify(id, otp, function (err, response) {
if (err) {
console.log({ error: err.errors[0].description, id: id });
res.json({ error: err.errors[0].description, id: id });
@ -125,16 +128,22 @@ module.exports.getOTP = (req, res, next) => {
console.log(err);
}
};
// Phone verification End.
// -----------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------
// Email verification Starts
var transport = nodemailer.createTransport({
host: "smtp.mailtrap.io",
port: 2525,
service: "gmail",
auth: {
user: "5578544cc56856",
pass: "a510d3d969d3b3",
user: "5578544cc56856", //replace it with the companies mail
pass: "a510d3d969d3b3", //replace it with the companies pass
},
});
module.exports.forgotpassword = async (req, res, next) => {
const { email, link, _html, sending_company_email, subject } = req.body; //link = https://cantileverlabs.herokuapp.com/resetpassword/:id/:token
const { email, link, _html, sending_company_email, subject } = req.body;
//link = https://cantileverlabs.herokuapp.com/resetpassword/:id/:token
try {
await User.findOne({ email }).then((user) => {
if (!user) {
@ -180,7 +189,6 @@ module.exports.forgotpassword = async (req, res, next) => {
console.log("Error from forgot pass", error);
};
}
//verify email then set password.
};
module.exports.resetpassword = async (req, res, next) => {
const { _id, token } = req.params;
@ -217,6 +225,9 @@ module.exports.resetpassword = async (req, res, next) => {
}
};
// Email verification Ends
// -----------------------------------------------------------------------------------------------
module.exports.checkProtected = (req, res, next) => {
console.log(req.user);
res.json({