diff --git a/lib/server/v2/RequestContext.d.ts b/lib/server/v2/RequestContext.d.ts index e6c52321..28e14251 100644 --- a/lib/server/v2/RequestContext.d.ts +++ b/lib/server/v2/RequestContext.d.ts @@ -40,6 +40,7 @@ export declare class DefaultRequestContextExternalOptions implements RequestCont user: IUser; } export declare class RequestContext { + overridePrivileges: boolean; requested: RequestedResource; headers: RequestContextHeaders; server: WebDAVServer; diff --git a/lib/server/v2/RequestContext.js b/lib/server/v2/RequestContext.js index 5a256377..b8e2098b 100644 --- a/lib/server/v2/RequestContext.js +++ b/lib/server/v2/RequestContext.js @@ -87,6 +87,7 @@ var DefaultRequestContextExternalOptions = (function () { exports.DefaultRequestContextExternalOptions = DefaultRequestContextExternalOptions; var RequestContext = (function () { function RequestContext(server, uri, headers) { + this.overridePrivileges = false; this.headers = new RequestContextHeaders(headers); this.server = server; uri = url.parse(uri).pathname; diff --git a/lib/server/v2/commands/Lock.js b/lib/server/v2/commands/Lock.js index 202e6cb5..38f06f36 100644 --- a/lib/server/v2/commands/Lock.js +++ b/lib/server/v2/commands/Lock.js @@ -33,7 +33,9 @@ function createLock(ctx, data, callback) { var owner = ownerElement ? ownerElement.elements : null; var lock_1 = new Lock_1.Lock(new LockKind_1.LockKind(scope, type_1, ctx.server.options.lockTimeout), ctx.user ? ctx.user.uid : undefined, owner, ctx.headers.depth === undefined ? -1 : ctx.headers.depth); var go_1 = function (r, callback) { + ctx.overridePrivileges = true; r.listDeepLocks(function (e, locks) { + ctx.overridePrivileges = false; if (e) return callback(e); if (Object.keys(locks).length > 0) { @@ -83,6 +85,7 @@ function createLock(ctx, data, callback) { }); } catch (ex) { + console.log(ex); ctx.setCode(WebDAVRequest_1.HTTPCodes.BadRequest); callback(); return; diff --git a/lib/user/v2/privilege/PrivilegeManager.js b/lib/user/v2/privilege/PrivilegeManager.js index 009d733c..e462affd 100644 --- a/lib/user/v2/privilege/PrivilegeManager.js +++ b/lib/user/v2/privilege/PrivilegeManager.js @@ -14,7 +14,7 @@ var PrivilegeManager = (function () { PrivilegeManager.prototype.can = function (_fullPath, resource, _privilege, callback) { var _this = this; var user = resource.context.user; - if (user && user.isAdministrator) + if (resource.context.overridePrivileges || user && user.isAdministrator) return callback(null, true); if (_privilege.constructor !== String) { new Workflow_1.Workflow() diff --git a/src/server/v2/RequestContext.ts b/src/server/v2/RequestContext.ts index cc768245..db52de3e 100644 --- a/src/server/v2/RequestContext.ts +++ b/src/server/v2/RequestContext.ts @@ -109,6 +109,7 @@ export class DefaultRequestContextExternalOptions implements RequestContextExter export class RequestContext { + overridePrivileges : boolean requested : RequestedResource headers : RequestContextHeaders server : WebDAVServer @@ -116,6 +117,7 @@ export class RequestContext protected constructor(server : WebDAVServer, uri : string, headers : { [name : string] : string }) { + this.overridePrivileges = false; this.headers = new RequestContextHeaders(headers); this.server = server; diff --git a/src/server/v2/commands/Lock.ts b/src/server/v2/commands/Lock.ts index d7506b33..02a5cc65 100644 --- a/src/server/v2/commands/Lock.ts +++ b/src/server/v2/commands/Lock.ts @@ -8,6 +8,7 @@ import { LockType } from '../../../resource/lock/LockType' import { Errors } from '../../../Errors' import { Lock } from '../../../resource/lock/Lock' import { XML } from '../../../helper/XML' +import { IUser } from '../../../user/v2/IUser' import * as path from 'path' function createResponse(ctx : HTTPRequestContext, lock : Lock) @@ -44,7 +45,9 @@ function createLock(ctx : HTTPRequestContext, data : Buffer, callback) const go = (r : Resource, callback : SimpleCallback) => { + ctx.overridePrivileges = true; r.listDeepLocks((e, locks) => { + ctx.overridePrivileges = false; if(e) return callback(e); @@ -105,6 +108,7 @@ function createLock(ctx : HTTPRequestContext, data : Buffer, callback) } catch(ex) { + console.log(ex); ctx.setCode(HTTPCodes.BadRequest); callback(); return; diff --git a/src/user/v2/privilege/PrivilegeManager.ts b/src/user/v2/privilege/PrivilegeManager.ts index fd85ea29..33e5b3c2 100644 --- a/src/user/v2/privilege/PrivilegeManager.ts +++ b/src/user/v2/privilege/PrivilegeManager.ts @@ -36,7 +36,7 @@ export class PrivilegeManager can(_fullPath : Path | string, resource : Resource, _privilege : BasicPrivilege | string | BasicPrivilege[] | string[], callback : PrivilegeManagerCallback) : void { const user = resource.context.user; - if(user && user.isAdministrator) + if(resource.context.overridePrivileges || user && user.isAdministrator) return callback(null, true); if(_privilege.constructor !== String)