Skip to content

Commit

Permalink
Merge branch 'fix/815'
Browse files Browse the repository at this point in the history
  • Loading branch information
animalillo committed Oct 14, 2024
2 parents 18ca2b8 + 611e7aa commit 077724e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
18 changes: 15 additions & 3 deletions js/app/controllers/edit_credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
*/
Expand Down
11 changes: 8 additions & 3 deletions js/app/services/credentialservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,20 @@
encryptCredential: function (credential, key) {
for (var i = 0; i < _encryptedFields.length; i++) {
var field = _encryptedFields[i];
var fieldValue = angular.copy(credential[field]);
credential[field] = EncryptService.encryptString(JSON.stringify(fieldValue), key);
if (credential[field] !== undefined) {
var fieldValue = angular.copy(credential[field]);
credential[field] = EncryptService.encryptString(JSON.stringify(fieldValue), key);
}
}
return credential;
},
decryptCredential: function (credential, key) {
for (var i = 0; i < _encryptedFields.length; i++) {
var field = _encryptedFields[i];
var fieldValue = angular.copy(credential[field]);
var fieldValue = null;
if (credential[field] !== undefined) {
fieldValue = angular.copy(credential[field]);
}
var field_decrypted_value;
try {
if(fieldValue!==null && fieldValue!=="null" && fieldValue!==""){
Expand Down
2 changes: 1 addition & 1 deletion js/templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions templates/views/edit_credential.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<nav class="app-sidebar-tabs__nav">
<ul>
<li ng-repeat="tab in tabs track by $index" class="app-sidebar-tabs__tab"
ng-if="tab.requiredACL == undefined || storedCredential.acl == undefined || hasPermission(storedCredential.acl.permissions, tab.requiredACL)"
ng-class="isActiveTab(tab)? 'active' : 'inactive'"
ng-click="onClickTab(tab)">{{ tab.title }}
</li>
Expand Down

0 comments on commit 077724e

Please sign in to comment.