(js) Prohibit subscribing a user with no rights

pull/229/merge
Francis Lachapelle 2018-08-28 12:34:27 -04:00
parent dfcc14356a
commit 0e2c93864b
4 changed files with 28 additions and 1 deletions

6
NEWS
View File

@ -1,3 +1,9 @@
4.X.Y (2018-MM-DD)
------------------
Enhancements
- [web] prohibit subscribing a user with no rights
4.0.2 (2018-08-24)
------------------

View File

@ -77,7 +77,7 @@
<var:if condition="canSubscribeUsers">
<md-checkbox ng-model="user.isSubscribed"
label:arial-label="Subscribe User"
ng-disabled="user.wasSubscribed"
ng-disabled="user.wasSubscribed || acl.hasNoRight(user)"
ng-true-value="1"
ng-false-value="0"
ng-hide="user.$isSpecial()">

View File

@ -145,6 +145,22 @@
});
};
/**
* @function $hasNoRight
* @memberof Acl.prototype
* @desc Check if user has any rights on the resource
* @return true if user has no right at all
*/
Acl.prototype.$hasNoRight = function(user) {
var o = _.find(user.rights, function(value, right) {
if (angular.isNumber(value))
return (value === 1);
else
return (value !== 'None');
});
return _.isUndefined(o);
};
/**
* @function $resetUsersRights
* @memberof Acl.prototype

View File

@ -26,6 +26,7 @@
vm.addUser = addUser;
vm.selectAllRights = selectAllRights;
vm.selectUser = selectUser;
vm.hasNoRight = hasNoRight;
vm.showRights = showRights;
vm.confirmation = { showing: false,
message: ''};
@ -104,6 +105,10 @@
}
}
function hasNoRight(user) {
return folder.$acl.$hasNoRight(user);
}
function showRights(user) {
return vm.selectedUid == user.uid && !user.inactive;
}