Skip to content

Commit cd42e33

Browse files
author
nicola
committed
fixing undefined user and skipping Group, Owner-only and Glob
1 parent e1648c9 commit cd42e33

3 files changed

Lines changed: 72 additions & 542 deletions

File tree

‎lib/acl.js‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ACL.prototype.isAcl = function (resource) {
4343
}
4444

4545
ACL.prototype.can = function (user, mode, resource, callback, options) {
46-
debug('Can ' + user + ' ' + mode + ' ' + resource + '?')
46+
debug('Can ' + user || 'an agent' + ' ' + mode + ' ' + resource + '?')
4747
var self = this
4848
var accessType = 'accessTo'
4949
var acls = possibleACLs(resource, self.suffix)
@@ -82,6 +82,7 @@ ACL.prototype.can = function (user, mode, resource, callback, options) {
8282
accessType, // accessTo or defaultForNew
8383
acl, // The current Acl file!
8484
function (err) {
85+
console.log('current err', err)
8586
return next(!err || err)
8687
}, options)
8788
})
@@ -97,6 +98,8 @@ ACL.prototype.can = function (user, mode, resource, callback, options) {
9798
err = null
9899
}
99100

101+
console.log("error was", err)
102+
100103
if (err) {
101104
debug('Error: ' + err.message)
102105
if (!user || user.length === 0) {
@@ -110,6 +113,8 @@ ACL.prototype.can = function (user, mode, resource, callback, options) {
110113
}
111114
}
112115

116+
console.log("sending out", err)
117+
113118
return callback(err)
114119
})
115120
}
@@ -181,11 +186,15 @@ ACL.prototype.findRule = function (graph, user, mode, resource, accessType, acl,
181186
}
182187

183188
// Check for Agent
184-
var agentStatements = self.match(
185-
graph,
186-
statementSubject,
187-
'http://www.w3.org/ns/auth/acl#agent',
188-
user)
189+
var agentStatements = []
190+
191+
if (user) {
192+
agentStatements = self.match(
193+
graph,
194+
statementSubject,
195+
'http://www.w3.org/ns/auth/acl#agent',
196+
user)
197+
}
189198

190199
if (agentStatements.length) {
191200
debug(mode + ' access allowed (as agent) for: ' + user)

0 commit comments

Comments
 (0)