diff --git a/js/app/controllers/share.js b/js/app/controllers/share.js index a181ed97..89408d4f 100644 --- a/js/app/controllers/share.js +++ b/js/app/controllers/share.js @@ -291,36 +291,42 @@ angular.module('passmanApp') ShareService.generateSharedKey(20).then(function (key) { var encryptedSharedCredential = ShareService.encryptSharedCredential($scope.storedCredential, key); - encryptedSharedCredential.set_share_key = true; - CredentialService.updateCredential(encryptedSharedCredential, true).then(function (sharedCredential) { - $scope.storedCredential = ShareService.decryptSharedCredential(sharedCredential, key); - }); - - //@TODO Update files with new key (async) - // Files are stored in $scope.storedCredential.files - // They need get downloaded with FileService.getFile - // Then decrypt the data obtained with var EncryptService.decryptString(result.file_data); - // To update a file you can use the FileService.updateFile - - for (var f = 0; f < $scope.storedCredential.files.length; f++) { - var _file = $scope.storedCredential.files[f]; - FileService.getFile(_file).then(function (fileData) { - //Decrypt with old key - fileData.filename = EncryptService.decryptString(fileData.filename); - fileData.file_data = EncryptService.decryptString(fileData.file_data); - FileService.updateFile(fileData, key); - }) - } - - CredentialService.getRevisions($scope.storedCredential.guid).then(function (revisions) { - for (var r = 0; r < revisions.length; r++) { - var _revision = revisions[r]; - //Decrypt! - _revision.credential_data = CredentialService.decryptCredential(_revision.credential_data); - _revision.credential_data = ShareService.encryptSharedCredential(_revision.credential_data, key); - console.log('Used key for encrypting history ', key); - CredentialService.updateRevision(_revision); - } + // encryptedSharedCredential.set_share_key = true; + // CredentialService.updateCredential(encryptedSharedCredential, true).then(function (sharedCredential) { + // $scope.storedCredential = ShareService.decryptSharedCredential(sharedCredential, key); + // }); + // + // //@TODO Update files with new key (async) + // // Files are stored in $scope.storedCredential.files + // // They need get downloaded with FileService.getFile + // // Then decrypt the data obtained with var EncryptService.decryptString(result.file_data); + // // To update a file you can use the FileService.updateFile + // + // for (var f = 0; f < $scope.storedCredential.files.length; f++) { + // var _file = $scope.storedCredential.files[f]; + // FileService.getFile(_file).then(function (fileData) { + // //Decrypt with old key + // fileData.filename = EncryptService.decryptString(fileData.filename); + // fileData.file_data = EncryptService.decryptString(fileData.file_data); + // FileService.updateFile(fileData, key); + // }) + // } + // + // CredentialService.getRevisions($scope.storedCredential.guid).then(function (revisions) { + // for (var r = 0; r < revisions.length; r++) { + // var _revision = revisions[r]; + // //Decrypt! + // _revision.credential_data = CredentialService.decryptCredential(_revision.credential_data); + // _revision.credential_data = ShareService.encryptSharedCredential(_revision.credential_data, key); + // console.log('Used key for encrypting history ', key); + // CredentialService.updateRevision(_revision); + // } + // }); + var old_key = VaultService.getActiveVault().vaultKey + CredentialService.reencryptCredential(encryptedSharedCredential.id, old_key, key).progress(function(data){ + console.log(data); + }).then(function(data){ + console.log(data); }); //@TODO Update revisions with new key (async) diff --git a/js/app/services/credentialservice.js b/js/app/services/credentialservice.js index b8e829ce..8134388d 100644 --- a/js/app/services/credentialservice.js +++ b/js/app/services/credentialservice.js @@ -253,12 +253,12 @@ angular.module('passmanApp') this.promises ++; (new C_Promise(promise_files_update.bind(this))).progress(function(data){ this.call_progress(data); - }).then(function(data)){ + }).then(function(data){ this.promises --; if (this.promises == 0){ this.call_then("All done"); } - } + }); this.promises ++; (new C_Promise(promise_revisions_update.bind(this))).progress(function(data){ this.call_progress(data);