aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/models
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-05-14 10:36:32 +0200
committerDennis Eriksen <dennis.se@gmail.com>2013-05-14 10:36:32 +0200
commit950f81c7822e90f5f9e9b5d730cc99565072d6d9 (patch)
treeb5b21707ac4f358f3847b7638798e27d5933e2d1 /models
parentupdated the checkAccess-function to include permissions, and updated (diff)
downloadDivid-950f81c7822e90f5f9e9b5d730cc99565072d6d9.tar.gz
added check for permissions as well as check for access
Diffstat (limited to 'models')
-rw-r--r--models/Access.js10
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);