Skip to content

Commit

Permalink
Fixed the 'SimplePathPrivilegeManager' class to add sub-rights when c…
Browse files Browse the repository at this point in the history
…alling the 'setRights' method
  • Loading branch information
AdrienCastex committed Jul 3, 2017
1 parent feb1fe0 commit aaeed0c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/user/v2/privilege/SimplePathPrivilegeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ var SimplePathPrivilegeManager = (function (_super) {
throw Errors_1.Errors.IllegalArguments;
if (!this.rights[user.uid])
this.rights[user.uid] = {};
var rs = rights;
if (rs.indexOf('canRead') !== -1) {
rs.push('canReadLocks');
rs.push('canReadContent');
rs.push('canReadProperties');
}
if (rs.indexOf('canReadContent') !== -1) {
rs.push('canReadContentTranslated');
rs.push('canReadContentSource');
}
if (rs.indexOf('canWrite') !== -1) {
rs.push('canWriteLocks');
rs.push('canWriteContent');
rs.push('canWriteProperties');
}
if (rs.indexOf('canWriteContent') !== -1) {
rs.push('canWriteContentTranslated');
rs.push('canWriteContentSource');
}
this.rights[user.uid][standarizePath(path)] = rights;
};
SimplePathPrivilegeManager.prototype.getRights = function (user, path) {
Expand Down
25 changes: 25 additions & 0 deletions src/user/v2/privilege/SimplePathPrivilegeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ export class SimplePathPrivilegeManager extends PrivilegeManager

if(!this.rights[user.uid])
this.rights[user.uid] = {};

const rs = rights as string[];
if(rs.indexOf('canRead') !== -1)
{
rs.push('canReadLocks');
rs.push('canReadContent');
rs.push('canReadProperties');
}
if(rs.indexOf('canReadContent') !== -1)
{
rs.push('canReadContentTranslated');
rs.push('canReadContentSource');
}

if(rs.indexOf('canWrite') !== -1)
{
rs.push('canWriteLocks');
rs.push('canWriteContent');
rs.push('canWriteProperties');
}
if(rs.indexOf('canWriteContent') !== -1)
{
rs.push('canWriteContentTranslated');
rs.push('canWriteContentSource');
}

this.rights[user.uid][standarizePath(path)] = rights;
}
Expand Down

0 comments on commit aaeed0c

Please sign in to comment.