aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/models
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-05-13 00:29:03 +0200
committerDennis Eriksen <dennis.se@gmail.com>2013-05-13 00:29:03 +0200
commit7348573f1ba0312765b7a9397b0b43d5de47d4ff (patch)
tree584fdc4ddcad1877259325d28b0fc82e59a91eda /models
parentMerge branch 'master' of github.com:dennisse/Divid (diff)
downloadDivid-7348573f1ba0312765b7a9397b0b43d5de47d4ff.tar.gz
added a method to check user access. might not be used.. :(
Diffstat (limited to 'models')
-rw-r--r--models/Access.js22
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;
+ });
}
}