commit
aa699434ca
2
app.js
2
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());
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue