Ver Fonte

Updating merchant email now uses axios for email verification.

Lee Morgan há 5 anos atrás
pai
commit
93e7f9faa4

+ 1 - 1
controllers/emailVerification.js

@@ -12,8 +12,8 @@ module.exports = {
                 saveOwner = owner;
 
                 return axios({
-                    url: `https://api.mailgun.net/v3/mail.thesubline.net/messages`,
                     method: "post",
+                    url: `https://api.mailgun.net/v3/mail.thesubline.net/messages`,
                     headers: {
                         "Content-Type": "application/x-www-form-urlencoded"
                     },

+ 20 - 10
controllers/merchantData.js

@@ -7,9 +7,9 @@ const helper = require("./helper.js");
 const verifyEmail = require("../emails/verifyEmail.js");
 
 const bcrypt = require("bcryptjs");
-// const mailgun = require("mailgun-js")({apiKey: process.env.MG_SUBLINE_APIKEY, domain: "mail.thesubline.net"});
 const ObjectId = require("mongoose").Types.ObjectId;
 const axios = require("axios");
+const queryString = require("querystring");
 
 module.exports = {
     /*
@@ -261,16 +261,26 @@ module.exports = {
             res.locals.owner.email = req.body.email.toLowerCase();
             res.locals.owner.status.push("unverified");
 
-            const mailgunData = {
-                from: "The Subline <clientsupport@thesubline.net>",
-                to: res.locals.owner.email,
-                subject: "Email Verification",
-                html: verifyEmail({
-                    name: res.locals.owner.name,
-                    link: `${process.env.SITE}/verify/${res.locals.owner._id}/${res.locals.owner.session.sessionId}`
+            axios({
+                method: "post",
+                url: "https://api.mailgun.net/v3/mailg.thesubline.net/messages",
+                headers: {
+                    "Content-Type": "application/x-www-form-urlencoded",
+                },
+                auth: {
+                    username: "api",
+                    password: process.env.MG_SUBLINE_APIKEY
+                },
+                data: queryString.stringify({
+                    from: "The Subline <clientsupport@thesubline.net>",
+                    to: res.locals.owner.email,
+                    subject: "The Subline Email Verification",
+                    html: verifyEmail({
+                        name: res.locals.owner.name,
+                        link: `${process.env.SITE}/verify/${res.locals.owner._id}/${res.locals.owner.session.sessionId}`
+                    })
                 })
-            };
-            mailgun.messages().send(mailgunData, (err, body)=>{});
+            });
         }
 
         if(req.body.address !== "" && 

+ 0 - 11
controllers/passwordReset.js

@@ -18,17 +18,6 @@ module.exports = {
                     req.session.error = "USER WITH THIS EMAIL DOES NOT EXIST";
                     return res.redirect("/");
                 }
-                
-                // const mailgunData = {
-                //     from: "The Subline <clientsupport@thesubline.net>",
-                //     to: owner.email,
-                //     subject: "Password Reset",
-                //     html: passwordReset({
-                //         name: owner.name,
-                //         link: `${process.env.SITE}/reset/${owner._id}/${owner.session.sessionId}`
-                //     })
-                // };
-                // mailgun.messages().send(mailgunData, (err, body)=>{});
 
                 axios({
                     method: "post",