From 2af885265e47ab72f0209dd835f75b318e688330 Mon Sep 17 00:00:00 2001 From: brantje Date: Wed, 28 Sep 2016 23:40:33 +0200 Subject: [PATCH] Fix bugs --- js/app/controllers/credential.js | 4 ++-- js/app/controllers/edit_credential.js | 9 +++++---- js/app/controllers/settings.js | 1 + js/app/controllers/vault.js | 2 ++ js/app/services/vaultservice.js | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/js/app/controllers/credential.js b/js/app/controllers/credential.js index bbf7b111..459af364 100644 --- a/js/app/controllers/credential.js +++ b/js/app/controllers/credential.js @@ -22,6 +22,7 @@ angular.module('passmanApp') _vault.vaultKey = angular.copy(SettingsService.getSetting('defaultVaultPass')); VaultService.setActiveVault(_vault); $scope.active_vault = _vault; + //@TODO check if vault exists } @@ -30,7 +31,6 @@ angular.module('passmanApp') $scope.show_spinner = true; - var fetchCredentials = function () { VaultService.getVault($scope.active_vault).then(function (vault) { $scope.active_vault = angular.merge($scope.active_vault, vault); @@ -58,7 +58,7 @@ angular.module('passmanApp') if ($scope.active_vault) { $scope.$parent.selectedVault = true; - fetchCredentials(); + fetchCredentials() } diff --git a/js/app/controllers/edit_credential.js b/js/app/controllers/edit_credential.js index fe248fc4..6b2ba71c 100644 --- a/js/app/controllers/edit_credential.js +++ b/js/app/controllers/edit_credential.js @@ -10,6 +10,7 @@ angular.module('passmanApp') .controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService) { + $scope.active_vault = VaultService.getActiveVault(); if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) { if (!$scope.active_vault) { $location.path('/') @@ -18,7 +19,6 @@ angular.module('passmanApp') if (SettingsService.getSetting('defaultVault') && SettingsService.getSetting('defaultVaultPass')) { var _vault = angular.copy(SettingsService.getSetting('defaultVault')); VaultService.getVault(_vault).then(function (vault) { - vault.vaultKey = SettingsService.getSetting('defaultVaultPass'); VaultService.setActiveVault(vault); $scope.active_vault = vault; @@ -61,6 +61,7 @@ angular.module('passmanApp') }]; + if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) { if (!$scope.active_vault) { $location.path('/') @@ -80,7 +81,7 @@ angular.module('passmanApp') var storedCredential = SettingsService.getSetting('edit_credential'); if (!storedCredential) { - CredentialService.getCredential($routeParams.credential_id).then(function (result) { + CredentialService.getCredential($routeParams.credential_id).then(function(result){ $scope.storedCredential = CredentialService.decryptCredential(angular.copy(result)); }); } else { @@ -186,10 +187,10 @@ angular.module('passmanApp') $scope.renewIntervalValue = 0; $scope.renewIntervalModifier = '0'; - $scope.updateInterval = function (renewIntervalValue, renewIntervalModifier) { + $scope.updateInterval = function(renewIntervalValue, renewIntervalModifier){ var value = parseInt(renewIntervalValue); var modifier = parseInt(renewIntervalModifier); - if (value && modifier) { + if( value && modifier) { $scope.storedCredential.renew_interval = value * modifier; } }; diff --git a/js/app/controllers/settings.js b/js/app/controllers/settings.js index 288bc34f..a97859d7 100644 --- a/js/app/controllers/settings.js +++ b/js/app/controllers/settings.js @@ -11,6 +11,7 @@ angular.module('passmanApp') .controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$http', 'EncryptService', function ($scope, $rootScope, SettingsService, VaultService, CredentialService, $location, $routeParams, $http, EncryptService) { $scope.vault_settings = {}; + $scope.active_vault = VaultService.getActiveVault(); if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) { if (!$scope.active_vault) { $location.path('/') diff --git a/js/app/controllers/vault.js b/js/app/controllers/vault.js index 6b0d44fe..2959ce11 100644 --- a/js/app/controllers/vault.js +++ b/js/app/controllers/vault.js @@ -89,6 +89,7 @@ angular.module('passmanApp') var _loginToVault = function (vault, vault_key) { var _vault = angular.copy(vault); _vault.vaultKey = angular.copy(vault_key); + delete _vault.credentials; VaultService.setActiveVault(_vault); $location.path('/vault/' + vault.vault_id); }; @@ -98,6 +99,7 @@ angular.module('passmanApp') $scope.error = false; var _vault = angular.copy(vault); _vault.vaultKey = angular.copy(vault_key); + VaultService.setActiveVault(_vault); VaultService.getVault(vault).then(function (vault) { var credential = vault.credentials[0]; diff --git a/js/app/services/vaultservice.js b/js/app/services/vaultservice.js index 3d315809..aa1408b3 100644 --- a/js/app/services/vaultservice.js +++ b/js/app/services/vaultservice.js @@ -26,7 +26,7 @@ angular.module('passmanApp') setActiveVault: function(vault){ _activeVault = angular.copy(vault); }, - getActiveVault: function(vault){ + getActiveVault: function(){ return _activeVault; }, getVaultSetting: function(key, default_value){