moving and renaming
arnaucode arnaucode@gmail.com
Fri, 22 Sep 2017 19:21:32 +0200
23 files changed,
49 insertions(+),
10 deletions(-)
jump to
M
README.md
→
README.md
@@ -1,9 +1,9 @@
-# CarsInCommonServer +# commonroutesServer -- server code: https://github.com/arnaucode/carsincommonServer -- frontend app code: https://github.com/arnaucode/carsincommonApp +- server code: https://github.com/arnaucode/commonroutesServer +- frontend app code: https://github.com/arnaucode/commonroutesApp - images server: https://github.com/arnaucode/goImgServer -- admin web: https://github.com/arnaucode/carsincommonAdminWeb +- admin web: https://github.com/arnaucode/commonroutesAdminWeb **Backend:**@@ -18,8 +18,8 @@
App: - -code: https://github.com/arnaucode/carsincommonApp + +code: https://github.com/arnaucode/commonroutesApp --------------------
M
controllers/adminController.js
→
controllers/adminController.js
@@ -113,6 +113,15 @@ }
}); }; +exports.getAllAdmins = function(req, res) { + adminModel.find() + .limit(pageSize) + .skip(pageSize * Number(req.query.page)) + .exec(function(err, admins) { + if (err) return res.send(500, err.message); + res.status(200).jsonp(admins); + }); +}; exports.changePassword = function(req, res) { //if(req.body.) userModel.update({@@ -534,9 +543,22 @@ if (err) return res.send(500, err.message);
user.validated = true; user.validatedBy = admin._id; - user.save(function(err, user) { + var notification = new notificationModel({ + concept: "admin", + message: "an admin has validated your account", + date: new Date(), + icon: 'admin', + link: "users/" + user._id, + user: user._id + }); + notification.save(function(err, notification) { if (err) return res.send(500, err.message); - userController.getUserById(req, res); + + user.notifications.push(notification._id); + user.save(function(err, user) { + if (err) return res.send(500, err.message); + userController.getUserById(req, res); + }); }); }); }@@ -563,10 +585,24 @@ if (err) return res.send(500, err.message);
user.validated = false; user.validatedBy = admin._id; - user.save(function(err, user) { + var notification = new notificationModel({ + concept: "admin", + message: "an admin has unvalidated your account", + date: new Date(), + icon: 'admin', + link: "users/" + user._id, + user: user._id + }); + notification.save(function(err, notification) { if (err) return res.send(500, err.message); - userController.getUserById(req, res); + + user.notifications.push(notification._id); + user.save(function(err, user) { + if (err) return res.send(500, err.message); + userController.getUserById(req, res); + }); }); + }); } });