1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-21 16:35:04 -05:00

Merge pull request #341 from whiteout-io/dev/WO-726

[WO-726] Nuke user DB on logout
This commit is contained in:
Tankred Hase 2015-05-11 14:22:13 +02:00
commit b8f21ac7eb
4 changed files with 29 additions and 4 deletions

View File

@ -109,5 +109,5 @@ appCfg.string = {
connDocNoInbox: 'We could not detect an IMAP inbox folder on {0}. Please have a look at the FAQ for information on how to fix this error.',
connDocGenericError: 'There was an error connecting to {0}: {1}',
logoutTitle: 'Logout',
logoutMessage: 'Are you sure you want to logout?'
logoutMessage: 'Are you sure you want to log out? Please back up your encryption key before proceeding!'
};

View File

@ -194,7 +194,7 @@ var NavigationCtrl = function($scope, $location, $q, $timeout, account, email, o
if (!synced) {
dialog.confirm({
title: 'Key backup',
message: 'Your private key is not backed up. Back up now?',
message: 'Your encryption key is not backed up. Back up now?',
positiveBtnStr: 'Backup',
negativeBtnStr: 'Not now',
showNegativeBtn: true,

View File

@ -124,6 +124,10 @@ Account.prototype.logout = function() {
var self = this;
// clear app config store
return self._auth.logout().then(function() {
// clear the account DB, including keys and messages
return self._accountStore.clear();
}).then(function() {
// delete instance of imap-client and pgp-mailer
return self._emailDao.onDisconnect();

View File

@ -222,21 +222,42 @@ describe('Account Service unit test', function() {
});
describe('logout', function() {
// cannot test the good case here or the browser will refresh during the test.
it('should fail due to _auth.logout', function(done) {
authStub.logout.returns(rejects(new Error('asdf')));
account.logout().catch(function(err) {
expect(err.message).to.match(/asdf/);
expect(authStub.logout.calledOnce).to.be.true;
done();
});
});
it('should fail due to _accountStore.clear', function(done) {
authStub.logout.returns(resolves());
devicestorageStub.clear.returns(rejects(new Error('asdf')));
account.logout().catch(function(err) {
expect(err.message).to.match(/asdf/);
expect(devicestorageStub.clear.calledOnce).to.be.true;
expect(authStub.logout.calledOnce).to.be.true;
done();
});
});
it('should fail due to _emailDao.onDisconnect', function(done) {
authStub.logout.returns(resolves());
devicestorageStub.clear.returns(resolves());
emailStub.onDisconnect.returns(rejects(new Error('asdf')));
account.logout().catch(function(err) {
expect(err.message).to.match(/asdf/);
expect(emailStub.onDisconnect.calledOnce).to.be.true;
expect(authStub.logout.calledOnce).to.be.true;
expect(devicestorageStub.clear.calledOnce).to.be.true;
done();
});
});