diff options
author | Dennis Eriksen <dennis.se@gmail.com> | 2013-05-13 00:29:03 +0200 |
---|---|---|
committer | Dennis Eriksen <dennis.se@gmail.com> | 2013-05-13 00:29:03 +0200 |
commit | 7348573f1ba0312765b7a9397b0b43d5de47d4ff (patch) | |
tree | 584fdc4ddcad1877259325d28b0fc82e59a91eda /models | |
parent | Merge branch 'master' of github.com:dennisse/Divid (diff) | |
download | Divid-7348573f1ba0312765b7a9397b0b43d5de47d4ff.tar.gz |
added a method to check user access. might not be used.. :(
Diffstat (limited to 'models')
-rw-r--r-- | models/Access.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/models/Access.js b/models/Access.js index ce75f8c..ee62911 100644 --- a/models/Access.js +++ b/models/Access.js @@ -19,10 +19,6 @@ var AccessSchema = new Schema({ AccessSchema.statics = { - log: function() { - console.log('wat. wat logged this'); - }, - /** * Load ALL accesses for a single user * @@ -36,6 +32,24 @@ AccessSchema.statics = { .populate('project') .sort({ 'created': -1 }) // sort by date .exec(callback); + }, + + + /** + * Check to see if user has access to a particular project + * + * @param {ObjectId} user + * @param {ObjectId} project + * @return {Boolean} + * @api public + */ + + checkAccess: function(user, project) { + console.log('inni checkAccess!') + this.findOne({ user: user }).where('project').equals(project).exec(function(err, access) { + if (err || !access) return false; + else return true; + }); } } |