1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-21 23:08:50 -05:00

Fix bug for password decrypt in auth service

This commit is contained in:
Tankred Hase 2014-12-19 11:21:57 +01:00
parent b01aa6716c
commit cddc0988b7
2 changed files with 10 additions and 3 deletions

View File

@ -76,9 +76,13 @@ Auth.prototype.getCredentials = function() {
if (self.passwordNeedsDecryption) {
// decrypt password
return self._pgp.decrypt(self.password, undefined).then(function(cleartext) {
return self._pgp.decrypt(self.password, undefined).then(function(pt) {
if (!pt.signaturesValid) {
throw new Error('Verifying PGP signature of encrypted password failed!');
}
self.passwordNeedsDecryption = false;
self.password = cleartext;
self.password = pt.decrypted;
}).then(done);
}

View File

@ -74,7 +74,10 @@ describe('Auth unit tests', function() {
storageStub.listItems.withArgs(REALNAME_DB_KEY, 0, null).returns(resolves([realname]));
storageStub.listItems.withArgs(IMAP_DB_KEY, 0, null).returns(resolves([imap]));
storageStub.listItems.withArgs(SMTP_DB_KEY, 0, null).returns(resolves([smtp]));
pgpStub.decrypt.withArgs(encryptedPassword, undefined).returns(resolves(password));
pgpStub.decrypt.withArgs(encryptedPassword, undefined).returns(resolves({
decrypted: password,
signaturesValid: true
}));
auth.getCredentials().then(function(cred) {
expect(auth.emailAddress).to.equal(emailAddress);