From c42b1b9be8e57ca186b653b366ddddac6b0bedf2 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 14 May 2013 15:11:18 +0200 Subject: added method for retrieving user based on email --- models/User.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/models/User.js b/models/User.js index a40ba34..63f2d4a 100644 --- a/models/User.js +++ b/models/User.js @@ -158,6 +158,23 @@ UserSchema.methods = { } } +UserSchema.statics = { + + /** + * Load user from their email address + * + * @param {String} email + * @param {Function} callback + * @api private + */ + + loadUser: function(email, callback) { + this.findOne({ email: email }) + .exec(callback); + } + +} + mongoose.model('User', UserSchema); -- cgit v1.2.3