From a413d48e5fa4789007a42b8e99495b747928ba7f Mon Sep 17 00:00:00 2001 From: brantje Date: Thu, 6 Oct 2016 19:30:01 +0200 Subject: [PATCH] Fix for uploading files to a shared credential --- js/app/controllers/edit_credential.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/js/app/controllers/edit_credential.js b/js/app/controllers/edit_credential.js index bd061a0f..cd6e117c 100644 --- a/js/app/controllers/edit_credential.js +++ b/js/app/controllers/edit_credential.js @@ -155,15 +155,29 @@ angular.module('passmanApp') }; $scope.fileLoaded = function (file) { + var key; var _file = { filename: file.name, size: file.size, mimetype: file.type, data: file.data }; - FileService.uploadFile(_file).then(function (result) { + + if (!$scope.storedCredential.hasOwnProperty('acl') && $scope.storedCredential.hasOwnProperty('shared_key')) { + + if ($scope.storedCredential.shared_key) { + key = EncryptService.decryptString(angular.copy($scope.storedCredential.shared_key)); + } + } + + if ($scope.storedCredential.hasOwnProperty('acl')) { + key = EncryptService.decryptString(angular.copy($scope.storedCredential.acl.shared_key)); + } + + + FileService.uploadFile(_file, key).then(function (result) { delete result.file_data; - result.filename = EncryptService.decryptString(result.filename); + result.filename = EncryptService.decryptString(result.filename, key); $scope.storedCredential.files.push(result); });