1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 19:02:20 -05:00

Merge remote-tracking branch 'origin/dev/account-info'

This commit is contained in:
Tankred Hase 2013-11-06 17:03:05 +01:00
commit 4dac2b63a5
6 changed files with 112 additions and 3 deletions

View File

@ -12,6 +12,17 @@ define(function(require) {
var AccountCtrl = function($scope) { var AccountCtrl = function($scope) {
emailDao = appController._emailDao; emailDao = appController._emailDao;
//
// scope variables
//
var fpr = emailDao._crypto.getFingerprint(),
keyId = emailDao._crypto.getKeyId();
$scope.eMail = emailDao._account.emailAddress;
$scope.keyId = keyId.slice(0,4) + ' ' + keyId.slice(4,8) + ' ' + keyId.slice(8,12) + ' ' + keyId.slice(12);
$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 = emailDao._account.asymKeySize;
// //
// scope functions // scope functions
// //

View File

@ -43,6 +43,38 @@ define(function(require) {
}); });
}; };
/**
* Show a user's fingerprint
*/
PGP.prototype.getFingerprint = function() {
var publicKey, privateKey;
privateKey = openpgp.keyring.exportPrivateKey(0);
if (privateKey && privateKey.keyId) {
publicKey = openpgp.keyring.getPublicKeysForKeyId(privateKey.keyId)[0];
}
if (!privateKey || !privateKey.keyId || !privateKey.armored || !publicKey || !publicKey.armored) {
console.error('Public key not available!');
return '';
}
return util.hexstrdump(publicKey.obj.getFingerprint()).toUpperCase();
};
/**
* Show a user's key id
*/
PGP.prototype.getKeyId = function() {
var privateKey = openpgp.keyring.exportPrivateKey(0);
if (!privateKey || !privateKey.keyId) {
console.error('Public key not available!');
return '';
}
return util.hexstrdump(privateKey.keyId).toUpperCase();
};
/** /**
* Import the user's key pair * Import the user's key pair
*/ */

View File

@ -20,6 +20,7 @@
// Views // Views
@import "views/shared"; @import "views/shared";
@import "views/account";
@import "views/navigation"; @import "views/navigation";
@import "views/mail-list"; @import "views/mail-list";
@import "views/read"; @import "views/read";

View File

@ -0,0 +1,29 @@
.view-account {
padding: 0px;
color: $color-grey-dark;
@include respond-to(mobile) {
height: 100%;
}
table {
margin: 50px auto 100px auto;
td {
padding-top: 15px;
&:first-child {
text-align: right;
padding-right: 15px;
font-weight: bold;
}
}
}
button {
border: 0!important;
position: absolute;
bottom: 15px;
right: 15px;
}
}

View File

@ -5,6 +5,28 @@
</header> </header>
<div class="content"> <div class="content">
<button ng-click="exportKeyFile()" class="btn">Export keypair</button> <div class="view-account">
</div> <table summary="Kontakt">
</div> <tbody>
<tr>
<td>Account</td>
<td>{{eMail}}</td>
</tr>
<tr>
<td>PGP Key ID</td>
<td>{{keyId}}</td>
</tr>
<tr>
<td>PGP Key Fingerprint</td>
<td><span>{{fingerprint}}</span></td>
</tr>
<tr>
<td>PGP Key Size</td>
<td>{{keysize}} bit</td>
</tr>
</tbody>
</table>
<button ng-click="exportKeyFile()" class="btn">Export keypair</button>
</div><!-- /.view-account -->
</div><!-- /.content -->
</div><!-- /.lightbox-body -->

View File

@ -132,6 +132,20 @@ define(function(require) {
}); });
}); });
describe('Get KeyId', function() {
it('should work', function() {
var keyId = pgp.getKeyId();
expect(keyId).to.equal('F6F60E9B42CDFF4C');
});
});
describe('Get Fingerprint', function() {
it('should work', function() {
var fingerprint = pgp.getFingerprint();
expect(fingerprint).to.equal('5856CEF789C3A307E8A1B976F6F60E9B42CDFF4C');
});
});
describe('Encrypt', function() { describe('Encrypt', function() {
it('should work', function(done) { it('should work', function(done) {
pgp.encrypt(message, [pubkey], function(err, ct) { pgp.encrypt(message, [pubkey], function(err, ct) {