diff --git a/js/app/controllers/share.js b/js/app/controllers/share.js index e4209108..2662eaf8 100644 --- a/js/app/controllers/share.js +++ b/js/app/controllers/share.js @@ -101,12 +101,24 @@ angular.module('passmanApp') $scope.applyShare = function(){ console.log("boom!"); - var list = $scope.share_settings.credentialSharedWithUserAndGroup; - console.log(list); - for (var i = 0; i < list.length; i++){ - ShareService.getVaultsByUser(list[i].user_id).then(function(data){ - console.log(data); - }) - } + ShareService.generateSharedKey(20).then(function(key){ + console.log(key); + var list = $scope.share_settings.credentialSharedWithUserAndGroup; + console.log(list); + for (var i = 0; i < list.length; i++){ + ShareService.getVaultsByUser(list[i].userId).then(function(data){ + console.log(data); + for (var x = 0; x < data.length; x++) { + var rsa = ShareService.rsaPublicKeyFromPEM(data[x].public_sharing_key); + console.log("parsed RSA public key"); + var cyphertext = rsa.encrypt(key); + console.log(cyphertext); + cyphertext= forge.util.encode64(cyphertext); + console.log(cyphertext); + console.log(cyphertext.length); + } + }) + } + }) } }]); diff --git a/js/app/services/shareservice.js b/js/app/services/shareservice.js index 75080135..fddbd52b 100644 --- a/js/app/services/shareservice.js +++ b/js/app/services/shareservice.js @@ -27,7 +27,7 @@ angular.module('passmanApp') }, getVaultsByUser: function (userId) { var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/vaults/'+ userId); - return $http.get(queryUrl, {search: string}).then(function (response) { + return $http.get(queryUrl, {search: userId}).then(function (response) { if (response.data) { return response.data; } else { @@ -64,12 +64,13 @@ angular.module('passmanApp') generateSharedKey: function(size){ size = size || 20; return new C_Promise(function(){ + var t = this; CRYPTO.PASSWORD.generate(size, function(pass) { - this.call_then(pass); + t.call_then(pass); }, function(progress) { - this.call_progress(progress); + t.call_progress(progress); } ); })