mirror of
https://github.com/arnaucube/commonroutesServer.git
synced 2026-02-28 05:26:42 +01:00
added password change
This commit is contained in:
@@ -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:**
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user