var access = require('mongoose-access-plugin');
Model.plugin(access,function(operation,user){
if(user.role === "superadmin") return {}
if(user.role === "admin") return {company:user.company}
if(user.role === "user" && operation === "read") return {company:user.company}
return {creator:user._id}
});
Model.accessibleBy(req.user).find({priority:{$gte:3}}).exec(function(err,models){
//DO SOMETHING WITH YOUR MODELS HERE
});
Model.accessibleBy(req.user).findOneToUpdate(req.param.modelId).exec(function(err,model){
//UPDATE YOUR MODEL
});
Model.accessibleBy(req.user).findOneToDestroy(req.param.modelId).exec(function(err,model){
//DESTROY YOUR MODEL
});
-
Notifications
You must be signed in to change notification settings - Fork 0
A simple mongoose plugin to help streamline access control
License
christensenemc/mongoose-access-plugin
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A simple mongoose plugin to help streamline access control
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published