mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-10 13:36:55 +08:00
Fixed js permissions check
Improved default permissions handling
This commit is contained in:
parent
0a9c097910
commit
2084a16c55
4 changed files with 19 additions and 10 deletions
|
@ -77,6 +77,13 @@ angular.module('passmanApp')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.default_permissions = new SharingACL(0);
|
||||||
|
$scope.default_permissions.addPermission(
|
||||||
|
$scope.default_permissions.permissions.READ |
|
||||||
|
$scope.default_permissions.permissions.WRITE |
|
||||||
|
$scope.default_permissions.permissions.FILES
|
||||||
|
);
|
||||||
|
|
||||||
$scope.accessLevels = [
|
$scope.accessLevels = [
|
||||||
{
|
{
|
||||||
label: 'Can edit',
|
label: 'Can edit',
|
||||||
|
@ -99,7 +106,7 @@ angular.module('passmanApp')
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.hasPermission = function(acl, permission){
|
$scope.hasPermission = function(acl, permission){
|
||||||
console.log(acl, permission)
|
return acl.hasPermission(permission);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.shareWith = function (shareWith, selectedAccessLevel) {
|
$scope.shareWith = function (shareWith, selectedAccessLevel) {
|
||||||
|
@ -107,13 +114,11 @@ angular.module('passmanApp')
|
||||||
$scope.inputSharedWith = [];
|
$scope.inputSharedWith = [];
|
||||||
if (shareWith.length > 0) {
|
if (shareWith.length > 0) {
|
||||||
for (var i = 0; i < shareWith.length; i++) {
|
for (var i = 0; i < shareWith.length; i++) {
|
||||||
var acl = new SharingACL(0);
|
|
||||||
acl.addPermission(acl.permissions.READ | acl.permissions.WRITE | acl.permissions.FILES);
|
|
||||||
var obj = {
|
var obj = {
|
||||||
userId: shareWith[i].uid,
|
userId: shareWith[i].uid,
|
||||||
displayName: shareWith[i].text,
|
displayName: shareWith[i].text,
|
||||||
type: shareWith[i].type,
|
type: shareWith[i].type,
|
||||||
accessLevel: acl
|
acl: angular.copy($scope.default_permissions)
|
||||||
};
|
};
|
||||||
if ($scope.share_settings.credentialSharedWithUserAndGroup.indexOf(obj) === -1) {
|
if ($scope.share_settings.credentialSharedWithUserAndGroup.indexOf(obj) === -1) {
|
||||||
$scope.share_settings.credentialSharedWithUserAndGroup.push(obj)
|
$scope.share_settings.credentialSharedWithUserAndGroup.push(obj)
|
||||||
|
|
|
@ -21,7 +21,7 @@ angular.module('passmanApp').factory('SharingACL', function(){
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
ACL.prototype.hasPermission = function(permission){
|
ACL.prototype.hasPermission = function(permission){
|
||||||
return this.permission == (this.permission & permission);
|
return permission == (this.permission & permission);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,5 +40,9 @@ angular.module('passmanApp').factory('SharingACL', function(){
|
||||||
this.permission = this.permission & !permission;
|
this.permission = this.permission & !permission;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ACL.prototype.getAccessLevel = function() {
|
||||||
|
return this.permission;
|
||||||
|
};
|
||||||
|
|
||||||
return ACL;
|
return ACL;
|
||||||
});
|
});
|
|
@ -81,7 +81,7 @@ angular.module('views/partials/forms/settings/tool.html', []).run(['$templateCac
|
||||||
angular.module('views/partials/forms/share_credential/basics.html', []).run(['$templateCache', function($templateCache) {
|
angular.module('views/partials/forms/share_credential/basics.html', []).run(['$templateCache', function($templateCache) {
|
||||||
'use strict';
|
'use strict';
|
||||||
$templateCache.put('views/partials/forms/share_credential/basics.html',
|
$templateCache.put('views/partials/forms/share_credential/basics.html',
|
||||||
'<div class="row"><div class="col-xs-12 col-md-6"><div><table class="table sharing_table"><thead><tr><td><tags-input ng-model="inputSharedWith" replace-spaces-with-dashes="false" add-from-autocomplete-only="true" placeholder="Search users or groups..."><auto-complete source="searchUsers($query)" min-length="0" template="autocomplete-template"></auto-complete></tags-input></td><td><button class="button" ng-click="shareWith(inputSharedWith, selectedAccessLevel)">+</button></td></tr></thead></table><div ng-if="share_settings.cypher_progress.done > 0">Cyphering...<div progress-bar="share_settings.cypher_progress.percent" index="share_settings.cypher_progress.done" total="share_settings.cypher_progress.total"></div></div></div></div><div class="col-xs-12 col-md-6"><table class="table"><thead><tr><td>User</td><td>Crypto time</td></tr></thead><tr ng-repeat="user in share_settings.cypher_progress.times"><td><i class="fa fa-user"></i> {{user.user}}</td><td>{{user.time}} s</td></tr></table>Total time spent cyphering: {{ calculate_total_time() }}</div></div><div class="row"><div class="col-xs-12 col-md-6"><table class="table shared_table" ng-show="share_settings.credentialSharedWithUserAndGroup.length > 0"><thead><tr><td>User</td><td>Read</td><td>Write</td><td>Files</td><td>Revisions</td></tr></thead><tr ng-repeat="user in share_settings.credentialSharedWithUserAndGroup"><td><i class="fa fa-user" ng-if="user.type === \'user\'"></i> <i class="fa fa-group" ng-if="user.type === \'group\'"></i> {{user.userId}} {{user}}</td><td><input type="checkbox" ng-checked="hasPermission(user.acl, \'READ\')"></td><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr></table></div></div><script type="text/ng-template" id="autocomplete-template"><i class="fa fa-user" ng-if="data.type === \'user\'"></i>\n' +
|
'<div class="row"><div class="col-xs-12 col-md-6"><div><table class="table sharing_table"><thead><tr><td><tags-input ng-model="inputSharedWith" replace-spaces-with-dashes="false" add-from-autocomplete-only="true" placeholder="Search users or groups..."><auto-complete source="searchUsers($query)" min-length="0" template="autocomplete-template"></auto-complete></tags-input></td><td><button class="button" ng-click="shareWith(inputSharedWith, selectedAccessLevel)">+</button></td></tr></thead></table><div ng-if="share_settings.cypher_progress.done > 0">Cyphering...<div progress-bar="share_settings.cypher_progress.percent" index="share_settings.cypher_progress.done" total="share_settings.cypher_progress.total"></div></div></div></div><div class="col-xs-12 col-md-6"><table class="table"><thead><tr><td>User</td><td>Crypto time</td></tr></thead><tr ng-repeat="user in share_settings.cypher_progress.times"><td><i class="fa fa-user"></i> {{user.user}}</td><td>{{user.time}} s</td></tr></table>Total time spent cyphering: {{ calculate_total_time() }}</div></div><div class="row"><div class="col-xs-12 col-md-6"><table class="table shared_table" ng-show="share_settings.credentialSharedWithUserAndGroup.length > 0"><thead><tr><td>User</td><td>Read</td><td>Write</td><td>Files</td><td>Revisions</td></tr></thead><tr ng-repeat="user in share_settings.credentialSharedWithUserAndGroup"><td><i class="fa fa-user" ng-if="user.type === \'user\'"></i> <i class="fa fa-group" ng-if="user.type === \'group\'"></i> {{user.userId}} {{user}}</td><td><input type="checkbox" ng-checked="hasPermission(user.acl, default_permissions.permissions.READ)"></td><td><input type="checkbox" ng-checked="hasPermission(user.acl, default_permissions.permissions.WRITE)"></td><td><input type="checkbox" ng-checked="hasPermission(user.acl, default_permissions.permissions.FILES)"></td><td><input type="checkbox" ng-checked="hasPermission(user.acl, default_permissions.permissions.HISTORY)"></td></tr></table></div></div><script type="text/ng-template" id="autocomplete-template"><i class="fa fa-user" ng-if="data.type === \'user\'"></i>\n' +
|
||||||
' <i class="fa fa-group" ng-if="data.type === \'group\'"></i>\n' +
|
' <i class="fa fa-group" ng-if="data.type === \'group\'"></i>\n' +
|
||||||
' {{data.text}}</script>');
|
' {{data.text}}</script>');
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -70,10 +70,10 @@
|
||||||
{{user.userId}}
|
{{user.userId}}
|
||||||
{{user}}
|
{{user}}
|
||||||
</td>
|
</td>
|
||||||
<td><input type="checkbox" ng-checked="hasPermission(user.acl, 'READ')"> </td>
|
<td><input type="checkbox" ng-checked="hasPermission(user.acl, default_permissions.permissions.READ)"> </td>
|
||||||
<td><input type="checkbox"></td>
|
<td><input type="checkbox" ng-checked="hasPermission(user.acl, default_permissions.permissions.WRITE)"></td>
|
||||||
<td><input type="checkbox"></td>
|
<td><input type="checkbox" ng-checked="hasPermission(user.acl, default_permissions.permissions.FILES)"></td>
|
||||||
<td><input type="checkbox"></td>
|
<td><input type="checkbox" ng-checked="hasPermission(user.acl, default_permissions.permissions.HISTORY)"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue