Fix for downloading files (Firefox and chrome). Fixes #259

This commit is contained in:
brantje 2017-02-21 20:52:48 +01:00
parent 33d1a5db01
commit ce35286664
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
3 changed files with 26 additions and 24 deletions

View file

@ -409,27 +409,5 @@
$scope.delete_time = 0;
};
$scope.downloadFile = function (credential, file) {
var callback = function (result) {
var key = EncryptService.getSharedKeyFromCredential(credential);
if (!result.hasOwnProperty('file_data')) {
NotificationService.showNotification($translate.instant('error.loading.file.perm'), 5000);
return;
}
var file_data = EncryptService.decryptString(result.file_data, key);
download(file_data, escapeHTML(file.filename), file.mimetype);
};
if (!credential.hasOwnProperty('acl')) {
FileService.getFile(file).then(callback);
} else {
ShareService.downloadSharedFile(credential, file).then(callback);
}
};
}]);
}());

View file

@ -45,7 +45,7 @@
function countCredentials() {
var countedCredentials = 0;
var total = 0;
if(!scope.vault.hasOwnProperty('credentials')){
if(!scope.vault || !scope.vault.hasOwnProperty('credentials')){
return;
}

View file

@ -29,7 +29,8 @@
* # passwordGen
*/
angular.module('passmanApp')
.directive('credentialTemplate', [function () {
.directive('credentialTemplate', ['EncryptService', '$translate', 'FileService', 'ShareService', 'NotificationService', 'CredentialService',
function (EncryptService, $translate, FileService, ShareService, NotificationService, CredentialService) {
return {
templateUrl: 'views/partials/credential_template.html',
replace: true,
@ -39,6 +40,29 @@
},
link: function (scope, element, attrs) {
scope.downloadFile = function (credential, file) {
console.log('hi')
var callback = function (result) {
console.log(EncryptService);
var key = CredentialService.getSharedKeyFromCredential(credential);
if (!result.hasOwnProperty('file_data')) {
NotificationService.showNotification($translate.instant('error.loading.file.perm'), 5000);
return;
}
var file_data = EncryptService.decryptString(result.file_data, key);
download(file_data, escapeHTML(file.filename), file.mimetype);
};
if (!credential.hasOwnProperty('acl')) {
FileService.getFile(file).then(callback);
} else {
ShareService.downloadSharedFile(credential, file).then(callback);
}
};
scope.showLabel = (attrs.hasOwnProperty('showLabel'));
}
};