added password change
arnaucode idoctnef@openmailbox.org
Tue, 25 Jul 2017 22:53:45 +0200
3 files changed,
17 insertions(+),
2 deletions(-)
M
README.md
→
README.md
@@ -1,7 +1,9 @@
# CarsInCommonServer +- server code: https://github.com/arnaucode/carsincommonServer - frontend app code: https://github.com/arnaucode/carsincommonApp - images server: https://github.com/arnaucode/goImgServer +- admin web: https://github.com/arnaucode/carsincommonAdminWeb **Backend:**
M
controllers/userController.js
→
controllers/userController.js
@@ -5,7 +5,7 @@ var notificationModel = mongoose.model('notificationModel');
var travelModel = mongoose.model('travelModel'); var config = require('../config'); -var pageSize=config.pageSize; +var pageSize = config.pageSize; /* */ var jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens@@ -24,7 +24,8 @@ min = Math.ceil(min);
max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive } -function getAvatar(n){ + +function getAvatar(n) { switch (n) { case 1: avatar = "img/avatars/racoon.png";@@ -573,3 +574,13 @@ });
}); }); }; +exports.changePassword = function(req, res) { + //if(req.body.) + userModel.update({ + 'token': req.headers['x-access-token'] + }, req.body, + function(err) { + if (err) return console.log(err); + exports.getUserByToken(req, res); + }); +};
M
server.js
→
server.js
@@ -122,6 +122,8 @@ .get(userCtrl.getUserByToken);
apiRoutes.route('/users')//agafa l'user a partir del token .put(userCtrl.updateUser)//no comprovat .delete(userCtrl.deleteUser); +apiRoutes.route('/changePassword')//agafa l'user a partir del token + .put(userCtrl.changePassword); apiRoutes.route('/users/id/travels/:userid') .get(userCtrl.getTravelsByUserId);