mail/src/js/controller/account.js

44 lines
1.0 KiB
JavaScript
Raw Normal View History

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() {
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);
dl.createDownload({
content: keys.publicKeyArmored + keys.privateKeyArmored,
filename: id + '.asc',
contentType: 'text/plain'
}, onSave);
2013-10-21 11:10:45 -04:00
});
};
function onSave(err) {
if (err) {
console.error(err);
return;
}
}
2013-10-21 11:10:45 -04:00
};
return AccountCtrl;
});