diff options
Diffstat (limited to 'js/app')
-rw-r--r-- | js/app/controllers/settings.js | 71 | ||||
-rw-r--r-- | js/app/services/vaultservice.js | 27 |
2 files changed, 50 insertions, 48 deletions
diff --git a/js/app/controllers/settings.js b/js/app/controllers/settings.js index 9fa1f155..31d4a0a8 100644 --- a/js/app/controllers/settings.js +++ b/js/app/controllers/settings.js @@ -87,7 +87,9 @@ }); var btn_txt = $translate.instant('bookmarklet.text'); - var http = location.protocol, slashes = http.concat("//"), host = slashes.concat(window.location.hostname + ":" + window.location.port), complete = host + location.pathname; + var http = location.protocol, slashes = http.concat("//"), + host = slashes.concat(window.location.hostname + ":" + window.location.port), + complete = host + location.pathname; $scope.bookmarklet = $sce.trustAsHtml("<a class=\"button\" href=\"javascript:(function(){var a=window,b=document,c=encodeURIComponent,e=c(document.title),d=a.open('" + complete + "/bookmarklet?url='+c(b.location)+'&title='+e,'bkmk_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=750px,width=475px,resizable=0,alwaysRaised=1');a.setTimeout(function(){d.focus()},300);})();\">" + btn_txt + "</a>"); @@ -271,43 +273,36 @@ $scope.confirm_vault_delete = false; $scope.delete_vault_password = ''; - $scope.delete_vault = function() { - if ($scope.confirm_vault_delete && $scope.delete_vault_password === VaultService.getActiveVault().vaultKey) { - getCurrentVaultCredentials(function(vault) { - var credentials = vault.credentials; - $scope.remove_pw = { - percent: 0, - done: 0, - total: vault.credentials.length, - }; - var deleteCredential = function(index) { - $scope.translationData = { - password: credentials[index].label, - }; - CredentialService.destroyCredential(credentials[index].guid).then(function() { - var percent = index / vault.credentials.length * 100; - $scope.remove_pw = { - percent: percent, - done: index, - total: vault.credentials.length, - }; - if (index === credentials.length - 1) { - VaultService.deleteVault(vault).then(function() { - SettingsService.setSetting('defaultVaultPass', false); - SettingsService.setSetting('defaultVault', null); - $rootScope.$broadcast('logout'); - $location.path('/'); - }); - return; - } - deleteCredential(index + 1); - }); - }; - deleteCredential(0); - }); - } - - }; + $scope.delete_vault = function () { + if ($scope.confirm_vault_delete && $scope.delete_vault_password === VaultService.getActiveVault().vaultKey) { + getCurrentVaultCredentials(function (vault) { + var credentials = vault.credentials; + $scope.remove_pw = { + percent: 0, + done: 0, + total: vault.credentials.length, + }; + + var credential_guids = []; + var file_ids = []; + for (const credential of credentials) { + credential_guids.push(credential.guid); + var decryptedFiles = JSON.parse(EncryptService.decryptString(angular.copy(credential.files), VaultService.getActiveVault().vaultKey)); + for (const file of decryptedFiles) { + file_ids.push(file.file_id); + } + } + + VaultService.deleteVault(vault, credential_guids, file_ids).then(function () { + SettingsService.setSetting('defaultVaultPass', false); + SettingsService.setSetting('defaultVault', null); + $rootScope.$broadcast('logout'); + $location.path('/'); + }); + }); + } + + }; $rootScope.$on('logout', function () { $scope.active_vault = null; diff --git a/js/app/services/vaultservice.js b/js/app/services/vaultservice.js index 767466b5..79809b6e 100644 --- a/js/app/services/vaultservice.js +++ b/js/app/services/vaultservice.js @@ -66,7 +66,7 @@ return false; } else { _activeVault.vault_settings[key] = value; - this.updateVault(_activeVault); + this.updateVault(_activeVault); } }, @@ -122,21 +122,28 @@ } }); }, - deleteVault: function (vault) { + deleteVault: function (vault, credential_guids, file_ids) { var queryUrl = OC.generateUrl('apps/passman/api/v2/vaults/' + vault.guid); - return $http.delete(queryUrl).then(function (response) { - if (response.data) { - return response.data; - } else { - return response; - } + var deleteContentUrl = OC.generateUrl('apps/passman/api/v2/vaults/delete-vault-content'); + var data = { + "credential_guids": JSON.stringify(credential_guids), + "file_ids": JSON.stringify(file_ids) + }; + return $http.post(deleteContentUrl, data).then(function () { + return $http.delete(queryUrl).then(function (response) { + if (response.data) { + return response.data; + } else { + return response; + } + }); }); }, clearVaultService: function () { - _activeVault=null; + _activeVault = null; } }; return service; }]); -}());
\ No newline at end of file +}()); |