2014-10-02 16:05:44 -04:00
|
|
|
'use strict';
|
|
|
|
|
2014-11-20 09:14:39 -05:00
|
|
|
var AccountCtrl = function($scope, auth, keychain, pgp, appConfig, download, dialog) {
|
|
|
|
var userId = auth.emailAddress;
|
2014-11-26 11:57:14 -05:00
|
|
|
if (!userId) {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-02 16:05:44 -04:00
|
|
|
|
|
|
|
$scope.state.account = {
|
|
|
|
toggle: function(to) {
|
|
|
|
$scope.state.lightbox = (to) ? 'account' : undefined;
|
|
|
|
}
|
|
|
|
};
|
2013-10-21 11:10:45 -04:00
|
|
|
|
|
|
|
//
|
2014-10-02 16:05:44 -04:00
|
|
|
// scope variables
|
2013-10-21 11:10:45 -04:00
|
|
|
//
|
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
var keyParams = pgp.getKeyParams();
|
|
|
|
|
|
|
|
$scope.eMail = userId;
|
|
|
|
$scope.keyId = keyParams._id.slice(8);
|
|
|
|
var fpr = keyParams.fingerprint;
|
|
|
|
$scope.fingerprint = fpr.slice(0, 4) + ' ' + fpr.slice(4, 8) + ' ' + fpr.slice(8, 12) + ' ' + fpr.slice(12, 16) + ' ' + fpr.slice(16, 20) + ' ' + fpr.slice(20, 24) + ' ' + fpr.slice(24, 28) + ' ' + fpr.slice(28, 32) + ' ' + fpr.slice(32, 36) + ' ' + fpr.slice(36);
|
|
|
|
$scope.keysize = keyParams.bitSize;
|
2014-11-20 09:14:39 -05:00
|
|
|
$scope.publicKeyUrl = appConfig.config.cloudUrl + '/' + userId;
|
2014-10-02 16:05:44 -04:00
|
|
|
|
|
|
|
//
|
|
|
|
// scope functions
|
|
|
|
//
|
2013-10-21 11:10:45 -04:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
$scope.exportKeyFile = function() {
|
|
|
|
keychain.getUserKeyPair(userId, function(err, keys) {
|
|
|
|
if (err) {
|
2014-11-20 09:14:39 -05:00
|
|
|
dialog.error(err);
|
2014-10-02 16:05:44 -04:00
|
|
|
return;
|
2013-11-08 17:53:33 -05:00
|
|
|
}
|
2014-10-02 16:05:44 -04:00
|
|
|
|
|
|
|
var keyId = keys.publicKey._id;
|
|
|
|
var file = 'whiteout_mail_' + userId + '_' + keyId.substring(8, keyId.length);
|
|
|
|
|
2014-11-20 09:14:39 -05:00
|
|
|
download.createDownload({
|
2014-10-02 16:05:44 -04:00
|
|
|
content: keys.publicKey.publicKey + '\r\n' + keys.privateKey.encryptedKey,
|
|
|
|
filename: file + '.asc',
|
|
|
|
contentType: 'text/plain'
|
2013-10-21 11:10:45 -04:00
|
|
|
});
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
2013-10-21 11:10:45 -04:00
|
|
|
};
|
2014-10-02 16:05:44 -04:00
|
|
|
};
|
2013-10-21 11:10:45 -04:00
|
|
|
|
2014-10-08 06:34:34 -04:00
|
|
|
module.exports = AccountCtrl;
|