Przeglądaj źródła

Small changes to ensure working password recovery

Lee Morgan 6 lat temu
rodzic
commit
4c32f64d3d
4 zmienionych plików z 8 dodań i 13 usunięć
  1. 0 9
      branchNotes.txt
  2. 6 2
      controllers/otherData.js
  3. 1 1
      routes.js
  4. 1 1
      views/passResetPage/passReset.ejs

+ 0 - 9
branchNotes.txt

@@ -1,9 +0,0 @@
-I have updated the login and registration so that you can create an account and then login with it.
-
-1.  Create an account and check the rest of the website.
-    A lot of the work style that you changed affects every other page and breaks things.
-    This is why I told you you really should not add style to "shared.css" unless you are absolute certain that you want it to affect every single page.
-    You need to go through and get rid of all of these negative affects.
-    Maybe go through "shared.css" and move all that code to the more local "landing.css"
-
-Other than that, everything seems good to me.  Fix those side effects on the rest of the site and everything should be ready to go.

+ 6 - 2
controllers/otherData.js

@@ -103,12 +103,16 @@ module.exports = {
 
     /*
     POST - Changes the users password
+    req.body = {
+        pass: new password,
+        confirmPass: new password confirmation,
+        hash: hashed version of old password
+    }
     */
     resetPassword: function(req, res){
-        console.log(req.body);
         Merchant.findOne({password: req.body.hash})
             .then((merchant)=>{
-                if(merchant){
+                if(merchant && req.body.pass === req.body.confirmPass){
                     let salt = bcrypt.genSaltSync(10);
                     let hash = bcrypt.hashSync(req.body.pass, salt);
 

+ 1 - 1
routes.js

@@ -20,7 +20,7 @@ module.exports = function(app){
     app.put("/merchant/ingredients/add", merchantData.addMerchantIngredient);
     app.delete("/merchant/ingredients/remove/:id", merchantData.removeMerchantIngredient);
     app.put("/merchant/ingredients/update", merchantData.updateMerchantIngredient);
-    // app.post("/merchant/password", merchantData.updatePassword);
+    app.post("/merchant/password", merchantData.updatePassword);
 
     //Ingredients
     app.get("/ingredients", ingredientData.getIngredients);

+ 1 - 1
views/passResetPage/passReset.ejs

@@ -28,7 +28,7 @@
             </form>
         </div>
 
-        <script src="../shared/validation.js"></script>
+        <script src="/shared/validation.js"></script>
         <script>
             let submitPass = ()=>{
                 event.preventDefault();