[WO-726] Nuke user DB on logout

master
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.',
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!'
};

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 keys are 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();
});
});