-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathauthorization.js
More file actions
32 lines (25 loc) · 911 Bytes
/
authorization.js
File metadata and controls
32 lines (25 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var Class = require('sji');
var Authorization = module.exports = Class.extend({
init:function () {
},
// is request is authorized, callback false will return 401
is_authorized:function (req, callback) {
callback(null, true);
},
// USE ONLY WITH MONGOOSE RESOURCE
// limit an object list to only allow authorized data
limit_object_list:function (req, objects, callback) {
// add further filter on object list
callback(null, objects);
},
// USE ONLY WITH MONGOOSE RESOURCE
// limit single object, callback(null,object) to allow, callback(null,null) to block
limit_object:function (req, object, callback) {
callback(null, object);
},
// USE ONLY WITH MONGOOSE RESOURCE
edit_object:function (req, object, callback) {
// edits an object right before it's being saved
callback(null, object);
}
});