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:
parent
b01aa6716c
commit
cddc0988b7
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user