mirror of https://github.com/moparisthebest/mail
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) {
|
if (self.passwordNeedsDecryption) {
|
||||||
// decrypt password
|
// 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.passwordNeedsDecryption = false;
|
||||||
self.password = cleartext;
|
self.password = pt.decrypted;
|
||||||
}).then(done);
|
}).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(REALNAME_DB_KEY, 0, null).returns(resolves([realname]));
|
||||||
storageStub.listItems.withArgs(IMAP_DB_KEY, 0, null).returns(resolves([imap]));
|
storageStub.listItems.withArgs(IMAP_DB_KEY, 0, null).returns(resolves([imap]));
|
||||||
storageStub.listItems.withArgs(SMTP_DB_KEY, 0, null).returns(resolves([smtp]));
|
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) {
|
auth.getCredentials().then(function(cred) {
|
||||||
expect(auth.emailAddress).to.equal(emailAddress);
|
expect(auth.emailAddress).to.equal(emailAddress);
|
||||||
|
|
Loading…
Reference in New Issue