Fix loading vault if it's already open. Ref #263

Signed-off-by: brantje <brantje@gmail.com>
This commit is contained in:
brantje 2017-10-29 15:27:50 +01:00
parent fa814851cf
commit 34a920ec5c
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
2 changed files with 15 additions and 2 deletions

View file

@ -21,5 +21,4 @@ tools:
build_failure_conditions: build_failure_conditions:
- 'issues.label("coding-style").new.count > 5' - 'issues.label("coding-style").new.count > 5'
- 'issues.severity(>= MAJOR).new.exists' - 'issues.severity(>= MAJOR).new.exists'
- 'elements.rating(<= D).new.exists'
- 'project.metric("scrutinizer.quality", < 7.5)' - 'project.metric("scrutinizer.quality", < 7.5)'

View file

@ -58,6 +58,9 @@
vault.credentials = []; vault.credentials = [];
$scope.active_vault = vault; $scope.active_vault = vault;
$scope.active_vault.vaultKey = vaultKey; $scope.active_vault.vaultKey = vaultKey;
if(!$rootScope.vaultCache){
$rootScope.vaultCache = [];
}
VaultService.setActiveVault($scope.active_vault); VaultService.setActiveVault($scope.active_vault);
for (var i = 0; i < _credentials.length; i++) { for (var i = 0; i < _credentials.length; i++) {
var _credential = _credentials[i]; var _credential = _credentials[i];
@ -103,6 +106,7 @@
angular.merge($scope.active_vault.credentials, _credentials); angular.merge($scope.active_vault.credentials, _credentials);
$scope.show_spinner = false; $scope.show_spinner = false;
$rootScope.$broadcast('credentials_loaded'); $rootScope.$broadcast('credentials_loaded');
$rootScope.vaultCache[$scope.active_vault.guid] = angular.copy($scope.active_vault);
if(!vault.private_sharing_key){ if(!vault.private_sharing_key){
var key_size = 1024; var key_size = 1024;
ShareService.generateRSAKeys(key_size).then(function (kp) { ShareService.generateRSAKeys(key_size).then(function (kp) {
@ -135,13 +139,20 @@
var refresh_data_interval = null; var refresh_data_interval = null;
if ($scope.active_vault) { if ($scope.active_vault) {
$scope.$parent.selectedVault = true; $scope.$parent.selectedVault = true;
if($rootScope.vaultCache && $rootScope.vaultCache[$scope.active_vault.guid]){
$scope.active_vault = $rootScope.vaultCache[$scope.active_vault.guid];
$rootScope.$broadcast('credentials_loaded');
$scope.show_spinner = false;
} else {
fetchCredentials(); fetchCredentials();
}
getPendingShareRequests(); getPendingShareRequests();
refresh_data_interval = $interval(function () { refresh_data_interval = $interval(function () {
fetchCredentials(); fetchCredentials();
getPendingShareRequests(); getPendingShareRequests();
}, 60000 * 5); }, 60000 * 5);
} }
$scope.$on('$destroy', function () { $scope.$on('$destroy', function () {
$interval.cancel(refresh_data_interval); $interval.cancel(refresh_data_interval);
}); });
@ -399,6 +410,9 @@
}; };
$rootScope.$on('logout', function () { $rootScope.$on('logout', function () {
if($scope.active_vault) {
$rootScope.vaultCache[$scope.active_vault.guid] = null;
}
$scope.active_vault = null; $scope.active_vault = null;
$scope.credentials = []; $scope.credentials = [];
// $scope.$parent.selectedVault = false; // $scope.$parent.selectedVault = false;