diff --git a/www/js/controllers/login-controllers.js b/www/js/controllers/login-controllers.js index 8487c8333067cef4ea501c2314eb4206ba807feb..59b5b367b19dc4f158f098d133b2e2895a0b0396 100644 --- a/www/js/controllers/login-controllers.js +++ b/www/js/controllers/login-controllers.js @@ -337,9 +337,10 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils, $scope.formData.file = { name: file.fileData.name, - size: file.fileData.size + size: file.fileData.size, + content: file.fileContent }; - return CryptoUtils.parseKeyFileContent(file.fileContent, false/*withSecret*/) + return CryptoUtils.readKeyFile($scope.formData.file, false/*withSecret*/) .then(function(keypair) { if (!keypair || !keypair.signPk) { $scope.formData.file.valid = false; diff --git a/www/js/services/crypto-services.js b/www/js/services/crypto-services.js index 19833ed012bb07ccd93dd8ab59fbad40a8c2cf8f..3c0252378ff6b85877ff5e3f1ce301668c60b2ff 100644 --- a/www/js/services/crypto-services.js +++ b/www/js/services/crypto-services.js @@ -141,6 +141,11 @@ angular.module('cesium.crypto.services', ['cesium.utils.services']) CryptoAbstractService.prototype.readKeyFile = function(file, withSecret) { var that = this; + + if (file && file.content) { + return that.parseKeyFileContent(file.content, withSecret); + } + return $q(function(resolve, reject) { if (!file) { return reject('Argument [file] is missing'); @@ -149,8 +154,7 @@ angular.module('cesium.crypto.services', ['cesium.utils.services']) console.debug('[crypto] [keypair] reading file: ', file); var reader = new FileReader(); reader.onload = function (event) { - var res = that.parseKeyFileContent(event.target.result, withSecret); - res + that.parseKeyFileContent(event.target.result, withSecret) .then(function (res) { resolve(res); })