2013-10-21 11:10:45 -04:00
|
|
|
define(function(require) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var appController = require('js/app-controller'),
|
2013-10-23 11:17:36 -04:00
|
|
|
dl = require('js/util/download'),
|
2013-10-21 11:10:45 -04:00
|
|
|
emailDao;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Controller
|
|
|
|
//
|
|
|
|
|
|
|
|
var AccountCtrl = function($scope) {
|
|
|
|
emailDao = appController._emailDao;
|
|
|
|
|
|
|
|
//
|
|
|
|
// scope functions
|
|
|
|
//
|
|
|
|
|
|
|
|
$scope.exportKeyFile = function() {
|
2013-10-22 10:12:18 -04:00
|
|
|
emailDao._crypto.exportKeys(function(err, keys) {
|
2013-10-21 11:10:45 -04:00
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-22 10:45:50 -04:00
|
|
|
var id = keys.keyId.substring(8, keys.keyId.length);
|
2013-11-04 15:07:32 -05:00
|
|
|
dl.createDownload({
|
|
|
|
content: keys.publicKeyArmored + keys.privateKeyArmored,
|
|
|
|
filename: id + '.asc',
|
|
|
|
contentType: 'text/plain'
|
|
|
|
}, onSave);
|
2013-10-21 11:10:45 -04:00
|
|
|
});
|
|
|
|
};
|
2013-11-04 15:07:32 -05:00
|
|
|
|
|
|
|
function onSave(err) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-10-21 11:10:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
return AccountCtrl;
|
|
|
|
});
|