From 8e0dfacd5133d4b1a80ac9e2fcf9db8b1b8af4a0 Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Tue, 19 May 2015 16:21:52 +0200 Subject: [PATCH 1/3] [WO-891] Add logout to passphrase dialog --- src/js/app-config.js | 4 +++- src/js/controller/login/login-existing.js | 16 +++++++++++++++- src/js/email/email.js | 6 ++++-- src/tpl/login-existing.html | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/js/app-config.js b/src/js/app-config.js index 0df91b4..287124d 100644 --- a/src/js/app-config.js +++ b/src/js/app-config.js @@ -109,5 +109,7 @@ 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 log out? Please back up your encryption key before proceeding!' + logoutMessage: 'Are you sure you want to log out? Please back up your encryption key before proceeding!', + removePreAuthAccountTitle: 'Remove account', + removePreAuthAccountMessage: 'Are you sure you want to remove this account from this device?' }; diff --git a/src/js/controller/login/login-existing.js b/src/js/controller/login/login-existing.js index 125db26..5191080 100644 --- a/src/js/controller/login/login-existing.js +++ b/src/js/controller/login/login-existing.js @@ -1,8 +1,10 @@ 'use strict'; -var LoginExistingCtrl = function($scope, $location, $routeParams, $q, email, auth, keychain) { +var LoginExistingCtrl = function($scope, $location, $routeParams, $q, email, auth, keychain, account, dialog, appConfig) { !$routeParams.dev && !auth.isInitialized() && $location.path('/'); // init app + var str = appConfig.string; + $scope.confirmPassphrase = function() { if ($scope.form.$invalid) { $scope.errMsg = 'Please fill out all required fields!'; @@ -38,6 +40,18 @@ var LoginExistingCtrl = function($scope, $location, $routeParams, $q, email, aut }).catch(displayError); }; + $scope.logout = function() { + return dialog.confirm({ + title: str.removePreAuthAccountTitle, + message: str.removePreAuthAccountMessage, + callback: function(confirm) { + if (confirm) { + account.logout().catch(dialog.error); + } + } + }); + }; + function displayError(err) { $scope.busy = false; $scope.incorrect = true; diff --git a/src/js/email/email.js b/src/js/email/email.js index d5c7043..e43525e 100644 --- a/src/js/email/email.js +++ b/src/js/email/email.js @@ -938,8 +938,10 @@ Email.prototype.onConnect = function(imap) { Email.prototype.onDisconnect = function() { // logout of imap-client // ignore error, because it's not problem if logout fails - this._imapClient.stopListeningForChanges(function() {}); - this._imapClient.logout(function() {}); + if (this._imapClient) { + this._imapClient.stopListeningForChanges(function() {}); + this._imapClient.logout(function() {}); + } // discard clients this._account.online = false; diff --git a/src/tpl/login-existing.html b/src/tpl/login-existing.html index cb8e642..2471293 100644 --- a/src/tpl/login-existing.html +++ b/src/tpl/login-existing.html @@ -25,7 +25,7 @@

- Forgot your passphrase? + Forgot the passphrase? Remove account from device.

From c3362c193da03f9c0e562088d5ba5b1e0f3acc47 Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Tue, 19 May 2015 17:39:30 +0200 Subject: [PATCH 2/3] Add missing mocks --- .../unit/controller/login/login-existing-ctrl-test.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/unit/controller/login/login-existing-ctrl-test.js b/test/unit/controller/login/login-existing-ctrl-test.js index d957e2f..4b293cb 100644 --- a/test/unit/controller/login/login-existing-ctrl-test.js +++ b/test/unit/controller/login/login-existing-ctrl-test.js @@ -1,12 +1,14 @@ 'use strict'; var Auth = require('../../../../src/js/service/auth'), + Account = require('../../../../src/js/email/account'), + Dialog = require('../../../../src/js/util/dialog'), LoginExistingCtrl = require('../../../../src/js/controller/login/login-existing'), EmailDAO = require('../../../../src/js/email/email'), KeychainDAO = require('../../../../src/js/service/keychain'); describe('Login (existing user) Controller unit test', function() { - var scope, location, ctrl, emailDaoMock, authMock, + var scope, location, ctrl, emailDaoMock, authMock, accountMock, dialogMock, emailAddress = 'fred@foo.com', passphrase = 'asd', keychainMock; @@ -15,6 +17,8 @@ describe('Login (existing user) Controller unit test', function() { emailDaoMock = sinon.createStubInstance(EmailDAO); authMock = sinon.createStubInstance(Auth); keychainMock = sinon.createStubInstance(KeychainDAO); + accountMock = sinon.createStubInstance(Account); + dialogMock = sinon.createStubInstance(Dialog); authMock.emailAddress = emailAddress; @@ -31,7 +35,10 @@ describe('Login (existing user) Controller unit test', function() { $q: window.qMock, email: emailDaoMock, auth: authMock, - keychain: keychainMock + keychain: keychainMock, + account: accountMock, + dialog: dialogMock, + appConfig: {} }); }); }); From 1d0efc02a28a65944a7420fe7b375fbbd187e101 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Tue, 19 May 2015 18:30:31 +0200 Subject: [PATCH 3/3] Review text --- src/js/app-config.js | 4 ++-- src/tpl/login-existing.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/app-config.js b/src/js/app-config.js index 287124d..3a8b0ed 100644 --- a/src/js/app-config.js +++ b/src/js/app-config.js @@ -111,5 +111,5 @@ appCfg.string = { logoutTitle: 'Logout', logoutMessage: 'Are you sure you want to log out? Please back up your encryption key before proceeding!', removePreAuthAccountTitle: 'Remove account', - removePreAuthAccountMessage: 'Are you sure you want to remove this account from this device?' -}; + removePreAuthAccountMessage: 'Are you sure you want to remove your account from this device?' +}; \ No newline at end of file diff --git a/src/tpl/login-existing.html b/src/tpl/login-existing.html index 2471293..d608411 100644 --- a/src/tpl/login-existing.html +++ b/src/tpl/login-existing.html @@ -25,7 +25,7 @@

- Forgot the passphrase? Remove account from device. + Forgot your passphrase?