User ID middleware now uses .findById

This commit is contained in:
Ilan Biala
2015-01-19 21:37:02 -05:00
parent 7b7b73d6e3
commit 121c38efbd

View File

@@ -11,9 +11,7 @@ var _ = require('lodash'),
* User middleware
*/
exports.userByID = function(req, res, next, id) {
User.findOne({
_id: id
}).exec(function(err, user) {
User.findById(id).exec(function(err, user) {
if (err) return next(err);
if (!user) return next(new Error('Failed to load User ' + id));
req.profile = user;
@@ -51,4 +49,4 @@ exports.hasAuthorization = function(roles) {
}
});
};
};
};