1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-25 10:22:18 -05:00

[WO-726] Nuke user DB on logout

This commit is contained in:
Felix Hammerl 2015-05-09 18:58:31 +02:00
parent add1cd3919
commit b35d993ff1
4 changed files with 27 additions and 2 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.', 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}', connDocGenericError: 'There was an error connecting to {0}: {1}',
logoutTitle: 'Logout', logoutTitle: 'Logout',
logoutMessage: 'Are you sure you want to logout?' logoutMessage: 'Are you sure you want to log out? Please back up your encryption keys before proceeding!'
}; };

View File

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

View File

@ -124,6 +124,10 @@ Account.prototype.logout = function() {
var self = this; var self = this;
// clear app config store // clear app config store
return self._auth.logout().then(function() { 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 // delete instance of imap-client and pgp-mailer
return self._emailDao.onDisconnect(); return self._emailDao.onDisconnect();

View File

@ -222,21 +222,42 @@ describe('Account Service unit test', function() {
}); });
describe('logout', 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) { it('should fail due to _auth.logout', function(done) {
authStub.logout.returns(rejects(new Error('asdf'))); authStub.logout.returns(rejects(new Error('asdf')));
account.logout().catch(function(err) { account.logout().catch(function(err) {
expect(err.message).to.match(/asdf/); 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(); done();
}); });
}); });
it('should fail due to _emailDao.onDisconnect', function(done) { it('should fail due to _emailDao.onDisconnect', function(done) {
authStub.logout.returns(resolves()); authStub.logout.returns(resolves());
devicestorageStub.clear.returns(resolves());
emailStub.onDisconnect.returns(rejects(new Error('asdf'))); emailStub.onDisconnect.returns(rejects(new Error('asdf')));
account.logout().catch(function(err) { account.logout().catch(function(err) {
expect(err.message).to.match(/asdf/); 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(); done();
}); });
}); });