From bd838e9e4684b035681dfb8adafbd964f33b0e84 Mon Sep 17 00:00:00 2001 From: Marcos Zuriaga Date: Mon, 3 Oct 2016 14:45:38 +0200 Subject: [PATCH] Added SharingACL factory Added license reference on some files --- js/app/controllers/share.js | 1 + js/app/factory/sharingacl.js | 42 +++++++++++++++++++++++++++++++++ js/app/services/shareservice.js | 1 + templates/main.php | 1 + 4 files changed, 45 insertions(+) create mode 100644 js/app/factory/sharingacl.js diff --git a/js/app/controllers/share.js b/js/app/controllers/share.js index c809eebe..bc0aec32 100644 --- a/js/app/controllers/share.js +++ b/js/app/controllers/share.js @@ -6,6 +6,7 @@ * @description * # MainCtrl * Controller of the passmanApp + * This file is part of passman, licensed under AGPLv3 */ angular.module('passmanApp') .controller('ShareCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService) { diff --git a/js/app/factory/sharingacl.js b/js/app/factory/sharingacl.js new file mode 100644 index 00000000..234300ae --- /dev/null +++ b/js/app/factory/sharingacl.js @@ -0,0 +1,42 @@ +/** + * Created by Marcos Zuriaga on 3/10/16. + * This file is part of passman, licensed under AGPLv3 + */ + +angular.module('passmanApp').factory('SharingACL', function(){ + function ACL(acl_permission){ + var permission = acl_permission; + var permissions = { + READ: 0x01, + WRITE: 0x03, + OWNER: 0x80, + }; + } + + /** + * Checks if a user has the given permission/s + * @param permission + * @returns {boolean} + */ + ACL.prototype.hasPermission = function(permission){ + return this.permission == (this.permission & permission); + }; + + /** + * Adds a permission to a user, leaving any other permissions intact + * @param permission + */ + ACL.prototype.addPermission = function(permission){ + this.permission = this.permission | permission; + }; + + /** + * Removes a given permission from the item, leaving any other intact + * @param permission + */ + ACL.prototype.removePermission = function(permission){ + this.permission = this.permission & !permission; + }; + + return ACL; +}); \ No newline at end of file diff --git a/js/app/services/shareservice.js b/js/app/services/shareservice.js index 2cef04f8..3e3931d7 100644 --- a/js/app/services/shareservice.js +++ b/js/app/services/shareservice.js @@ -6,6 +6,7 @@ * @description * # ShareService * Service in the passmanApp. + * This file is part of passman, licensed under AGPLv3 */ angular.module('passmanApp') .service('ShareService', ['$http', 'VaultService', 'EncryptService', 'CredentialService', function ($http, VaultService, EncryptService, CredentialService) { diff --git a/templates/main.php b/templates/main.php index 85d39334..c38b109a 100644 --- a/templates/main.php +++ b/templates/main.php @@ -54,6 +54,7 @@ script('passman', 'app/services/encryptservice'); script('passman', 'app/services/tagservice'); script('passman', 'app/services/notificationservice'); script('passman', 'app/services/shareservice'); +script('passman', 'app/factory/sharingacl'); script('passman', 'app/directives/passwordgen'); script('passman', 'app/directives/fileselect'); script('passman', 'app/directives/progressbar');