From 950f81c7822e90f5f9e9b5d730cc99565072d6d9 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 14 May 2013 10:36:32 +0200 Subject: added check for permissions as well as check for access --- models/Access.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'models') diff --git a/models/Access.js b/models/Access.js index bde5b4a..9302339 100644 --- a/models/Access.js +++ b/models/Access.js @@ -48,21 +48,25 @@ AccessSchema.statics = { }, - /** + /** * Check to see if user has access to a particular project * * @param {ObjectId} user * @param {ObjectId} project + * @param {Number} permissisons * @param {Function} callback * @api private */ - checkAccess: function(user, project, callback) { - console.log('inni checkAccess!') + checkAccess: function(user, project, permissions, callback) { + if (typeof(permissions) === 'undefined') permissions = 0; + console.log('inni checkPermissions!') this.findOne({ user: user }) .where('project').equals(project) + .where('permissions').gte(permissions) .exec(callback); } + } mongoose.model('Access', AccessSchema); -- cgit v1.2.3