From f1c5ba4b2bdaacbacbf7e1bca5a39d973d077d13 Mon Sep 17 00:00:00 2001 From: yashraj verma Date: Wed, 12 May 2021 17:18:25 +0530 Subject: [PATCH 1/2] Push Emails added --- controllers/auth.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/controllers/auth.js b/controllers/auth.js index 807b04e..92e390f 100644 --- a/controllers/auth.js +++ b/controllers/auth.js @@ -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({ From ef4c9b6a526e0ef10b94f271654809ce636d8ab0 Mon Sep 17 00:00:00 2001 From: yashraj verma Date: Wed, 12 May 2021 17:19:42 +0530 Subject: [PATCH 2/2] done --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 217a4fa..43635e8 100644 --- a/app.js +++ b/app.js @@ -18,7 +18,7 @@ const cors = require("cors"); const app = express(); -const MONGO_URI = `mongodb+srv://Cantilever:Cantilever@cluster0.dqxva.mongodb.net/myFirstDatabase?retryWrites=true&w=majority`; +const MONGO_URI = `mongodb+srv://${process.env.MONGO_USER}:${process.env.MONGO_PASSWORD}@cluster0.dqxva.mongodb.net/${process.env.MONGO_DEFAULT_DATABASE}?retryWrites=true&w=majority`; app.use(cors()); app.use(bodyparser.json());