diff --git a/src/js/app-config.js b/src/js/app-config.js index 45eabf7..171e147 100644 --- a/src/js/app-config.js +++ b/src/js/app-config.js @@ -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 keys before proceeding!' }; \ No newline at end of file diff --git a/src/js/controller/app/navigation.js b/src/js/controller/app/navigation.js index 4ae457d..22baca5 100644 --- a/src/js/controller/app/navigation.js +++ b/src/js/controller/app/navigation.js @@ -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 keys are not backed up. Back up now?', positiveBtnStr: 'Backup', negativeBtnStr: 'Not now', showNegativeBtn: true, diff --git a/src/js/email/account.js b/src/js/email/account.js index 9d72bfc..a74751f 100644 --- a/src/js/email/account.js +++ b/src/js/email/account.js @@ -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(); diff --git a/test/unit/email/account-test.js b/test/unit/email/account-test.js index 36b38d7..02e590f 100644 --- a/test/unit/email/account-test.js +++ b/test/unit/email/account-test.js @@ -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(); }); });