Skip to content

Commit 71fbd20

Browse files
committed
[fix] Login using file + drag&drop failed - Fix #696
1 parent b39973e commit 71fbd20

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

www/js/controllers/login-controllers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,10 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils,
337337

338338
$scope.formData.file = {
339339
name: file.fileData.name,
340-
size: file.fileData.size
340+
size: file.fileData.size,
341+
content: file.fileContent
341342
};
342-
return CryptoUtils.parseKeyFileContent(file.fileContent, false/*withSecret*/)
343+
return CryptoUtils.readKeyFile($scope.formData.file, false/*withSecret*/)
343344
.then(function(keypair) {
344345
if (!keypair || !keypair.signPk) {
345346
$scope.formData.file.valid = false;

www/js/services/crypto-services.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ angular.module('cesium.crypto.services', ['cesium.utils.services'])
141141

142142
CryptoAbstractService.prototype.readKeyFile = function(file, withSecret) {
143143
var that = this;
144+
145+
if (file && file.content) {
146+
return that.parseKeyFileContent(file.content, withSecret);
147+
}
148+
144149
return $q(function(resolve, reject) {
145150
if (!file) {
146151
return reject('Argument [file] is missing');
@@ -149,8 +154,7 @@ angular.module('cesium.crypto.services', ['cesium.utils.services'])
149154
console.debug('[crypto] [keypair] reading file: ', file);
150155
var reader = new FileReader();
151156
reader.onload = function (event) {
152-
var res = that.parseKeyFileContent(event.target.result, withSecret);
153-
res
157+
that.parseKeyFileContent(event.target.result, withSecret)
154158
.then(function (res) {
155159
resolve(res);
156160
})

0 commit comments

Comments
 (0)