Browse Source

added password change

master
arnaucode 7 years ago
parent
commit
b8c9d0c459
3 changed files with 17 additions and 2 deletions
  1. +2
    -0
      README.md
  2. +13
    -2
      controllers/userController.js
  3. +2
    -0
      server.js

+ 2
- 0
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:**

+ 13
- 2
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 @@ function getRand(min, max) {
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.doUnfav = function(req, res) {
});
});
};
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);
});
};

+ 2
- 0
server.js

@ -122,6 +122,8 @@ apiRoutes.route('/users/token')
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);

Loading…
Cancel
Save