From 611e7aa069be829689f767c0db120e99c4eaa864 Mon Sep 17 00:00:00 2001 From: binsky Date: Sun, 22 Sep 2024 16:42:57 +0200 Subject: [PATCH] hide credential edit files tab for shared credentials with missing FILES acl #815 --- js/app/controllers/edit_credential.js | 18 +++++++++++++++--- js/templates.js | 2 +- templates/views/edit_credential.html | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/js/app/controllers/edit_credential.js b/js/app/controllers/edit_credential.js index 4c38f210..44cc6479 100644 --- a/js/app/controllers/edit_credential.js +++ b/js/app/controllers/edit_credential.js @@ -32,8 +32,8 @@ * Controller of the passmanApp */ angular.module('passmanApp') - .controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService', '$translate','$rootScope', - function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, $translate, $rootScope) { + .controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService', 'SharingACL', '$translate','$rootScope', + function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, SharingACL, $translate, $rootScope) { $scope.active_vault = VaultService.getActiveVault(); if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) { if (!$scope.active_vault) { @@ -89,7 +89,8 @@ }, { title: translations.files, url: 'views/partials/forms/edit_credential/files.html', - color: 'yellow' + color: 'yellow', + requiredACL: $scope.permissions.permissions.FILES }, { title: translations.otp, url: 'views/partials/forms/edit_credential/otp.html', @@ -135,6 +136,17 @@ return tab.url === $scope.currentTab.url; }; + $scope.permissions = new SharingACL(0); + + $scope.hasPermission = function (acl, permission) { + if (acl) { + var tmp = new SharingACL(acl.permission); + return tmp.hasPermission(permission); + } else { + return true; + } + }; + /** * Below general edit functions */ diff --git a/js/templates.js b/js/templates.js index 2025b5ac..1893dcb4 100644 --- a/js/templates.js +++ b/js/templates.js @@ -9,7 +9,7 @@ angular.module('views/credential_revisions.html', []).run(['$templateCache', fun angular.module('views/edit_credential.html', []).run(['$templateCache', function($templateCache) { 'use strict'; $templateCache.put('views/edit_credential.html', - '
'); + '
'); }]); angular.module('views/partials/credential_template.html', []).run(['$templateCache', function($templateCache) { diff --git a/templates/views/edit_credential.html b/templates/views/edit_credential.html index 715b971f..c29b67b5 100644 --- a/templates/views/edit_credential.html +++ b/templates/views/edit_credential.html @@ -21,6 +21,7 @@