diff options
author | Felix Nüsse <Felix.nuesse@t-online.de> | 2018-11-23 20:15:18 +0300 |
---|---|---|
committer | fnuesse <felix.nuesse@t-online.de> | 2018-11-23 22:07:17 +0300 |
commit | ea23930352037553d75dc25ca9de47a1ce12ad69 (patch) | |
tree | 841d358a9fe1d31525b8460f3454e2ff6f133dcb /js/app | |
parent | abaedc1e38ccbbaac182b04437cdb4741e6c852a (diff) |
Added proper returnvalue to updatemethod of credentials and add the resulting value to the list if it does not exist or replace it if it exists
Fixed Nullpointer on listadd
Signed-off-by: Felix Nüsse <Felix.nuesse@t-online.de>
Diffstat (limited to 'js/app')
-rw-r--r-- | js/app/controllers/credential.js | 1 | ||||
-rw-r--r-- | js/app/controllers/edit_credential.js | 20 |
2 files changed, 16 insertions, 5 deletions
diff --git a/js/app/controllers/credential.js b/js/app/controllers/credential.js index f6d445c1..cb82461d 100644 --- a/js/app/controllers/credential.js +++ b/js/app/controllers/credential.js @@ -319,7 +319,6 @@ }; $rootScope.$on('push_decrypted_credential_to_list', function () { - $scope.active_vault = $rootScope.vaultCache[$scope.active_vault.guid]; $rootScope.$broadcast('credentials_loaded'); }); diff --git a/js/app/controllers/edit_credential.js b/js/app/controllers/edit_credential.js index 14acc04c..0cfaff6a 100644 --- a/js/app/controllers/edit_credential.js +++ b/js/app/controllers/edit_credential.js @@ -317,8 +317,6 @@ $location.path('/vault/' + $routeParams.vault_id); NotificationService.showNotification($translate.instant('credential.created'), 5000); - console.log("new cred"); - console.log(new_cred); $scope.updateExistingListWithCredential(new_cred); }); @@ -349,11 +347,13 @@ if(_credential.description && _credential.description !== "") { _credential.description = _credential.description.replace(regex, ""); } - CredentialService.updateCredential(_credential, _useKey).then(function () { + CredentialService.updateCredential(_credential, _useKey).then(function (updated_cred) { $scope.saving = false; SettingsService.setSetting('edit_credential', null); $location.path('/vault/' + $routeParams.vault_id); NotificationService.showNotification($translate.instant('credential.updated'), 5000); + + $scope.updateExistingListWithCredential(updated_cred); }); } @@ -369,7 +369,19 @@ } credential.tags_raw = credential.tags; - $rootScope.vaultCache[$scope.active_vault.guid].credentials.push(credential); + + var found=false; + var credList=$rootScope.vaultCache[$scope.active_vault.guid].credentials; + for (var i = 0; i < credList.length; i++) { + if(credList[i].credential_id==credential.credential_id){ + $rootScope.vaultCache[$scope.active_vault.guid].credentials[i]=credential; + found=true; + } + } + + if(!found){ + $rootScope.vaultCache[$scope.active_vault.guid].credentials.push(credential); + } $rootScope.$broadcast('push_decrypted_credential_to_list', credential); } catch (e) { |