diff options
author | fnuesse <felix.nuesse@t-online.de> | 2018-11-23 03:29:48 +0300 |
---|---|---|
committer | fnuesse <felix.nuesse@t-online.de> | 2018-11-23 03:29:48 +0300 |
commit | ce138267d2450b2d2480d07485495b74fb784624 (patch) | |
tree | cf2c63a5cafd6ccd067d5ff7c6f7944989ac30c4 /js/app | |
parent | d90626bc8e0bb1a90b9148ecc8705daead777597 (diff) |
Added decryption to proper credentialelement after creating a new credential
Signed-off-by: fnuesse <felix.nuesse@t-online.de>
Diffstat (limited to 'js/app')
-rw-r--r-- | js/app/controllers/credential.js | 31 | ||||
-rw-r--r-- | js/app/controllers/edit_credential.js | 53 |
2 files changed, 58 insertions, 26 deletions
diff --git a/js/app/controllers/credential.js b/js/app/controllers/credential.js index 303635f1..4a52dc5c 100644 --- a/js/app/controllers/credential.js +++ b/js/app/controllers/credential.js @@ -59,7 +59,7 @@ $scope.active_vault = vault; $scope.active_vault.vaultKey = vaultKey; if(!$rootScope.vaultCache){ - $rootScope.vaultCache = []; + $rootScope.vaultCache = []; } VaultService.setActiveVault($scope.active_vault); for (var i = 0; i < _credentials.length; i++) { @@ -136,16 +136,27 @@ + $rootScope.$on('push_decrypted_credential_to_list', function (event, args) { + console.log("Update List with:"); + console.log(args); + //$rootScope.active_vault.credentials.push(args); + updateList(args); + }); + + var updateList = function (args) { + $scope.credentials.push(args); + }; + var refresh_data_interval = null; if ($scope.active_vault) { $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(); - } + $scope.active_vault = $rootScope.vaultCache[$scope.active_vault.guid]; + $rootScope.$broadcast('credentials_loaded'); + $scope.show_spinner = false; + } else { + fetchCredentials(); + } getPendingShareRequests(); refresh_data_interval = $interval(function () { fetchCredentials(); @@ -411,11 +422,11 @@ $rootScope.$on('logout', function () { if($scope.active_vault) { - $rootScope.vaultCache[$scope.active_vault.guid] = null; - } + $rootScope.vaultCache[$scope.active_vault.guid] = null; + } $scope.active_vault = null; $scope.credentials = []; -// $scope.$parent.selectedVault = false; + //$scope.$parent.selectedVault = false; }); diff --git a/js/app/controllers/edit_credential.js b/js/app/controllers/edit_credential.js index 5c9ad4f0..3199d600 100644 --- a/js/app/controllers/edit_credential.js +++ b/js/app/controllers/edit_credential.js @@ -32,8 +32,8 @@ * Controller of the passmanApp */ angular.module('passmanApp') - .controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService', '$translate', - function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, $translate) { + .controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService', '$translate','$rootScope', + function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, $translate, $rootScope) { $scope.active_vault = VaultService.getActiveVault(); if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) { if (!$scope.active_vault) { @@ -186,12 +186,12 @@ }; $scope.addFileToCustomField = function (file) { - $scope.new_custom_field.value = { - filename: file.name, - size: file.size, - mimetype: file.type, - data: file.data - }; + $scope.new_custom_field.value = { + filename: file.name, + size: file.size, + mimetype: file.type, + data: file.data + }; $scope.$digest(); }; @@ -290,19 +290,19 @@ }; $scope.$digest(); }; + $scope.saving = false; - $scope.saveCredential = function () { - $scope.saving = true; + $scope.saveCredential = function () { + $scope.saving = true; if ($scope.new_custom_field.label && $scope.new_custom_field.value) { $scope.storedCredential.custom_fields.push(angular.copy($scope.new_custom_field)); } - if ($scope.storedCredential.password !== $scope.storedCredential.password_repeat){ - $scope.saving = false; - NotificationService.showNotification($translate.instant('password.do.not.match'), 5000); + $scope.saving = false; + NotificationService.showNotification($translate.instant('password.do.not.match'), 5000); return; } @@ -312,12 +312,17 @@ if (!$scope.storedCredential.credential_id) { $scope.storedCredential.vault_id = $scope.active_vault.vault_id; - CredentialService.createCredential($scope.storedCredential).then(function () { - $scope.saving = false; + CredentialService.createCredential($scope.storedCredential).then(function (new_cred) { + $scope.saving = false; $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); }); + + } else { var key, _credential; @@ -345,7 +350,7 @@ _credential.description = _credential.description.replace(regex, ""); } CredentialService.updateCredential(_credential, _useKey).then(function () { - $scope.saving = false; + $scope.saving = false; SettingsService.setSetting('edit_credential', null); $location.path('/vault/' + $routeParams.vault_id); NotificationService.showNotification($translate.instant('credential.updated'), 5000); @@ -354,6 +359,22 @@ }; + $scope.updateExistingListWithCredential = function (credential) { + try { + if (!credential.shared_key) { + credential = CredentialService.decryptCredential(credential); + } else { + var enc_key = EncryptService.decryptString(credential.shared_key); + credential = ShareService.decryptSharedCredential(credential, enc_key); + } + credential.tags_raw = credential.tags; + $rootScope.$broadcast('push_decrypted_credential_to_list', credential); + } catch (e) { + NotificationService.showNotification($translate.instant('error.decrypt'), 5000); + console.log(e); + } + }; + $scope.cancel = function () { $location.path('/vault/' + $routeParams.vault_id); }; |