Jelajahi Sumber

Add comments to square backend.
Display square log in button again.

Lee Morgan 5 tahun lalu
induk
melakukan
f12736ad6b
2 mengubah file dengan 9 tambahan dan 5 penghapusan
  1. 6 2
      controllers/squareData.js
  2. 3 3
      views/otherPages/login.ejs

+ 6 - 2
controllers/squareData.js

@@ -10,9 +10,11 @@ module.exports = {
         return res.redirect(`${process.env.SQUARE_ADDRESS}/oauth2/authorize?client_id=${process.env.SUBLINE_SQUARE_APPID}&scope=INVENTORY_READ+ITEMS_READ+MERCHANT_PROFILE_READ+ORDERS_READ+PAYMENTS_READ`);
     },
 
+    //GET: Used by square. This route is used for the authentication code
+    //Redirects to either dashboard or new merchant creation
     authorize: function(req, res){
         const code = req.url.slice(req.url.indexOf("code=") + 5, req.url.indexOf("&"));
-        const url = `${process.env.SQUARE_ADDRESS}/oauth2/token?`;
+        const url = `${process.env.SQUARE_ADDRESS}/oauth2/token`;
         let data = {
             client_id: process.env.SUBLINE_SQUARE_APPID,
             client_secret: process.env.SUBLINE_SQUARE_APPSECRET,
@@ -31,7 +33,7 @@ module.exports = {
     
                     return merchant.save()
                         .then((merchant)=>{
-                            req.session.user = merchant._id;
+                            req.session.user = merchant.session.sessionId;
                             return res.redirect("/dashboard");
                         })
                         .catch((err)=>{
@@ -51,6 +53,8 @@ module.exports = {
             });
     },
 
+    //GET: Gathers all data from square to create our merchant
+    //Redirects to the dashboard
     createMerchant: function(req, res){
         let merchant = {}
     

+ 3 - 3
views/otherPages/login.ejs

@@ -33,11 +33,11 @@
     
             <input id="signIn" type="submit" value="Sign In with Email">
     
-            <!-- <h1>OR</h1>
+            <h1>OR</h1>
     
-            <a class="button buttonWithBorder" href="/cloverlogin">Sign In with Clover</a>
+            <!-- <a class="button buttonWithBorder" href="/cloverlogin">Sign In with Clover</a> -->
     
-            <a class="button buttonWithBorder" href="/squarelogin">Sign In with Square</a> -->
+            <a class="button buttonWithBorder" href="/squarelogin">Sign In with Square</a>
             
             <a href="/reset/email" class="link">Forgot your password?</a>