From 088d32d1f2f0e2bc07fa9869cc2cb33028f0075f Mon Sep 17 00:00:00 2001 From: brantje Date: Wed, 28 Sep 2016 18:15:47 +0200 Subject: [PATCH] Remove credential cache --- js/app/controllers/credential.js | 72 ++++++++++++-------------------- 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/js/app/controllers/credential.js b/js/app/controllers/credential.js index 56921fd1..33e6615a 100644 --- a/js/app/controllers/credential.js +++ b/js/app/controllers/credential.js @@ -202,56 +202,38 @@ angular.module('passmanApp') }); $scope.show_spinner = true; - // A timeout give the browser some time to render a loading spinner. - $timeout(function(){ - try { - var credential_cache = JSON.parse(CacheService.get('credential_cache_' + $scope.active_vault.vault_id)); - if (credential_cache.length > 0) { - $scope.show_spinner = false; - $scope.credentials = credential_cache; - for (var i = 0; i < credential_cache.length; i++) { - TagService.addTags(credential_cache[i].tags_raw); + + var fetchCredentials = function () { + VaultService.getVault($scope.active_vault).then(function (credentials) { + var _credentials = []; + for (var i = 0; i < credentials.length; i++) { + try { + var _c = CredentialService.decryptCredential(angular.copy(credentials[i])); + } catch (e) { + NotificationService.showNotification('An error happend during decryption', 5000); + $rootScope.$broadcast('logout'); + SettingsService.setSetting('defaultVaultPass', null); + SettingsService.setSetting('defaultVault', null); + $location.path('/') + + } + if (_c) { + _c.tags_raw = _c.tags; + TagService.addTags(_c.tags); + _credentials.push(_c); } } - } catch (e) { + $scope.credentials = _credentials; + $scope.show_spinner = false; - } + }); + }; - var fetchCredentials = function () { - VaultService.getVault($scope.active_vault).then(function (credentials) { - var _credentials = []; - for (var i = 0; i < credentials.length; i++) { - try { - var _c = CredentialService.decryptCredential(angular.copy(credentials[i])); - } catch (e){ - CacheService.set('credential_cache_' + $scope.active_vault.vault_id, []); - NotificationService.showNotification('An error happend during decryption', 5000); - $rootScope.$broadcast('logout'); - SettingsService.setSetting('defaultVaultPass', null); - SettingsService.setSetting('defaultVault', null); - $location.path('/') - - } - if(_c) { - _c.tags_raw = _c.tags; - TagService.addTags(_c.tags); - _credentials.push(_c); - } - } - $scope.credentials = _credentials; - $scope.show_spinner = false; - CacheService.set('credential_cache_' + $scope.active_vault.vault_id, JSON.stringify(_credentials)); - - }); - }; - - if ($scope.active_vault) { - $scope.$parent.selectedVault = true; - fetchCredentials(); - } - - }, 50); + if ($scope.active_vault) { + $scope.$parent.selectedVault = true; + fetchCredentials(); + } $scope.downloadFile = function (file) {