Skip to content

Commit

Permalink
catch err
Browse files Browse the repository at this point in the history
  • Loading branch information
bourgeoa committed Apr 15, 2023
1 parent 9684cca commit 6822a82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/handlers/allow.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ function allow (mode) {
}
}

// check user is owner. Check isOwner from /.meta
if (resourceUrl.endsWith('.acl') && await ldp.isOwner(userId, req.hostname)) return next()

// check if user is owner. Check isOwner from /.meta
try {
if (resourceUrl.endsWith('.acl') && (await ldp.isOwner(userId, req.hostname))) return next()
} catch (err) {}
const error = req.authError || await req.acl.getError(userId, mode)
debug(`${mode} access denied to ${userId || '(none)'}: ${error.status} - ${error.message}`)
next(error)
Expand Down
7 changes: 7 additions & 0 deletions test/integration/ldp-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ describe('LDP', function () {
assert.equal(isOwner, true)
})
})
it('should return acl:owner false', () => {
const owner = 'https://tim.localhost:7777/profile/card'
return ldp.isOwner(owner, '/resources/')
.then(isOwner => {
assert.equal(isOwner, false)
})
})
})
describe('getGraph', () => {
it('should read and parse an existing file', () => {
Expand Down

0 comments on commit 6822a82

Please sign in to comment.