Skip to content

Commit

Permalink
Allowed a lock to not have a 'userUid' leading to skip the user check…
Browse files Browse the repository at this point in the history
…ing when testing the user privileges
  • Loading branch information
AdrienCastex committed Jun 19, 2017
1 parent 9d5b3c9 commit 0a9ca37
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/user/privilege/IPrivilegeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function requirePrivilege(privilege, arg, resource, callback) {
exports.requirePrivilege = requirePrivilege;
function hasNoWriteLock(arg, resource, callback) {
resource.getLocks(function (e, locks) {
var hasNoLock = locks ? locks.filter(function (l) { return l.userUid !== arg.user.uid && l.lockKind.type.isSame(LockType_1.LockType.Write); }).length === 0 : false;
var hasNoLock = locks ? locks.filter(function (l) { return (!l.userUid || l.userUid !== arg.user.uid) && l.lockKind.type.isSame(LockType_1.LockType.Write); }).length === 0 : false;
if (!hasNoLock || !resource.parent)
callback(e, hasNoLock);
else
Expand Down
2 changes: 1 addition & 1 deletion src/user/privilege/IPrivilegeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export interface IPrivilegeManager
export function hasNoWriteLock(arg : MethodCallArgs, resource : IResource, callback : PrivilegeManagerCallback)
{
resource.getLocks((e, locks) => {
const hasNoLock = locks ? locks.filter((l) => l.userUid !== arg.user.uid && l.lockKind.type.isSame(LockType.Write)).length === 0 : false;
const hasNoLock = locks ? locks.filter((l) => (!l.userUid || l.userUid !== arg.user.uid) && l.lockKind.type.isSame(LockType.Write)).length === 0 : false;
if(!hasNoLock || !resource.parent)
callback(e, hasNoLock);
else
Expand Down

0 comments on commit 0a9ca37

Please sign in to comment.