Browse Source

Owners now have a name when they sign up from square.
Merchants are now named for the location on signup.
Emails send owner name.

Lee Morgan 5 years ago
parent
commit
1de5735eae
3 changed files with 5 additions and 2 deletions
  1. 2 2
      controllers/emailVerification.js
  2. 2 0
      controllers/squareData.js
  3. 1 0
      models/owner.js

+ 2 - 2
controllers/emailVerification.js

@@ -12,7 +12,7 @@ module.exports = {
                     to: owner.email,
                     subject: "Email verification",
                     html: verifyEmail({
-                        name: owner.email,
+                        name: owner.name,
                         link: `${process.env.SITE}/verify/${owner._id}/${owner.session.sessionId}`,
                     })
                 };
@@ -67,7 +67,7 @@ module.exports = {
                 const memberData = {
                     subscribed: true,
                     address: owner.email,
-                    name: owner.email,
+                    name: owner.name,
                     vars: {}
                 }
                 mailgunList.members().create(memberData, (err, data)=>{});

+ 2 - 0
controllers/squareData.js

@@ -107,6 +107,7 @@ module.exports = {
             })    
             .then((response)=>{
                 merchant.locationId = response.data.merchant.main_location_id;
+                owner.name = response.data.merchant.business_name;
 
                 let items = axios.post(`${process.env.SQUARE_ADDRESS}/v2/catalog/search`, {
                     object_types: ["ITEM"]
@@ -126,6 +127,7 @@ module.exports = {
             })
             .then((response)=>{
                 if(owner.email === response[1].data.location.business_email) merchant.status = [];
+                merchant.name = response[1].data.location.name;
                 
                 let recipes = helper.createRecipesFromSquare(response[0].data.objects, merchant._id);
                 merchant.recipes = recipes;

+ 1 - 0
models/owner.js

@@ -12,6 +12,7 @@ const OwnerSchema = new mongoose.Schema({
         },
         index: true
     },
+    name: String,
     password: {
         type: String,
         required: true