Jelajahi Sumber

Create checks for new users

Lee Morgan 6 tahun lalu
induk
melakukan
b3b5de371a
3 mengubah file dengan 20 tambahan dan 3 penghapusan
  1. 7 2
      controllers/merchantData.js
  2. 12 0
      views/landingPage/register.js
  3. 1 1
      views/shared/header.ejs

+ 7 - 2
controllers/merchantData.js

@@ -4,7 +4,6 @@ const bcrypt = require("bcryptjs");
 const Merchant = require("../models/merchant");
 const Recipe = require("../models/recipe");
 const InventoryAdjustment = require("../models/inventoryAdjustment");
-const RecipeChange = require("../models/recipeChange");
 
 module.exports = {
     /*
@@ -17,7 +16,13 @@ module.exports = {
     }
     Redirects to /dashboard
     */
-    createMerchantNone: function(req, res){
+    createMerchantNone: async function(req, res){
+        let merchant = await Merchant.find({email: req.body.email.toLowerCase()});
+        if(merchant){
+            req.session.error = "That email address is already in use";
+            return res.redirect("/");
+        }
+
         if(req.body.password === req.body.confirmPassword){
             let salt = bcrypt.genSaltSync(10);
             let hash = bcrypt.hashSync(req.body.password, salt);

+ 12 - 0
views/landingPage/register.js

@@ -24,6 +24,18 @@ let registerObj = {
         let form = document.querySelector("#registerStrand form");
         let checkbox = document.querySelector("#checkAgree");
 
+        if(!checkbox.checked){
+            banner.createError("Please agree to the Privacy Policy and Terms and Conditions to continue");
+            return;
+        }
+
+        let pass = document.getElementById("regPass").value;
+        let confirmPass = document.getElementById("regConfirmPass").value;
+        if(pass !== confirmPass){
+            banner.createError("Your passwords do not match");
+            return;
+        }
+
         if(checkbox.checked){
             if(validator.isSanitary(document.querySelector("#regName").value)){
                 form.action = "merchant/create/none";

+ 1 - 1
views/shared/header.ejs

@@ -1,5 +1,5 @@
 <div class="header">
-    <a class="logo" href="http://www.thesubline.com" >
+    <a class="logo" href="/" >
         <img src="/shared/images/logo.png" alt="Subline">
         <div class='header-logo'> SUBLINE </div>
     </a>