diff options
author | Dennis Eriksen <dennis.se@gmail.com> | 2013-05-14 10:36:32 +0200 |
---|---|---|
committer | Dennis Eriksen <dennis.se@gmail.com> | 2013-05-14 10:36:32 +0200 |
commit | 950f81c7822e90f5f9e9b5d730cc99565072d6d9 (patch) | |
tree | b5b21707ac4f358f3847b7638798e27d5933e2d1 /models/Access.js | |
parent | updated the checkAccess-function to include permissions, and updated (diff) | |
download | Divid-950f81c7822e90f5f9e9b5d730cc99565072d6d9.tar.gz |
added check for permissions as well as check for access
Diffstat (limited to 'models/Access.js')
-rw-r--r-- | models/Access.js | 10 |
1 files changed, 7 insertions, 3 deletions
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); |