Explorar el Código

Route to Clover login. Doesn't work because app is not yet approved. Going in blind now.

Lee Morgan hace 6 años
padre
commit
8142b10dd5
Se han modificado 5 ficheros con 13 adiciones y 4 borrados
  1. 1 1
      app.js
  2. 9 1
      controllers/otherData.js
  3. 1 0
      routes.js
  4. 1 1
      views/landingPage/controller.js
  5. 1 1
      views/landingPage/landing.ejs

+ 1 - 1
app.js

@@ -4,7 +4,7 @@ const mongoose = require("mongoose");
 
 const app = express();
 
-mongoose.connect(process.env.SUBLINE, {useNewUrlParser: true, useUnifiedTopology: true});
+mongoose.connect(process.env.SUBLINE_DB, {useNewUrlParser: true, useUnifiedTopology: true});
 
 app.set("view engine", "ejs");
 

+ 9 - 1
controllers/otherData.js

@@ -184,7 +184,10 @@ module.exports = {
     },
 
     //POST - check an email for uniqueness
-    //
+    //Inputs:
+    //  req.body.email: email to check
+    //Returns:
+    //  Boolean
     checkUniqueEmail: function(req, res){
         Merchant.findOne({email: req.body.email})
             .then((merchant)=>{
@@ -205,5 +208,10 @@ module.exports = {
 
                 return res.json(errorMessage);
             });
+    },
+
+    //Get - Redirects user to Clover OAuth page
+    cloverAuth: function(req, res){
+        return res.redirect(`${process.env.CLOVER_ADDRESS}/oauth/authorize?client_id=${process.env.SUBLINE_CLOVER_APPID}&redirect_uri=localhost:8080/clover`);
     }
 }

+ 1 - 0
routes.js

@@ -34,4 +34,5 @@ module.exports = function(app){
     app.post("/login", otherData.login);
     app.get("/logout", otherData.logout);
     app.post("/email", otherData.checkUniqueEmail);
+    app.get("/cloverauth", otherData.cloverAuth);
 }

+ 1 - 1
views/landingPage/controller.js

@@ -7,7 +7,7 @@ let controller = {
         if(error){
             banner.createError(error);
         }
-        
+
         publicObj.display();
     },
 

+ 1 - 1
views/landingPage/landing.ejs

@@ -73,7 +73,7 @@
             <h1>Choose your POS System</h1>
 
             <div class="cards">
-                <a href="/merchant/new/clover">
+                <a href="/cloverauth">
                     <img src="../shared/images/clover-logo.jpeg" alt="Clover">
                 </a>