mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-02-28 01:00:59 +01:00
23 lines
409 B
JavaScript
23 lines
409 B
JavaScript
|
|
'use strict';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Module dependencies.
|
||
|
|
*/
|
||
|
|
var _ = require('lodash'),
|
||
|
|
mongoose = require('mongoose'),
|
||
|
|
User = mongoose.model('User');
|
||
|
|
|
||
|
|
/**
|
||
|
|
* User middleware
|
||
|
|
*/
|
||
|
|
exports.userByID = function(req, res, next, id) {
|
||
|
|
User.findOne({
|
||
|
|
_id: id
|
||
|
|
}).exec(function(err, user) {
|
||
|
|
if (err) return next(err);
|
||
|
|
if (!user) return next(new Error('Failed to load User ' + id));
|
||
|
|
req.profile = user;
|
||
|
|
next();
|
||
|
|
});
|
||
|
|
};
|