From ed00d950428839af0831ee04e97a69e493914aa2 Mon Sep 17 00:00:00 2001 From: Karl Ranna Date: Thu, 20 Sep 2018 14:47:53 +0300 Subject: [PATCH 1/2] Clear password field if incorrectly entered --- src/action/wallet.js | 1 + test/unit/action/wallet.spec.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/action/wallet.js b/src/action/wallet.js index 8a937a82c..ff966a845 100644 --- a/src/action/wallet.js +++ b/src/action/wallet.js @@ -298,6 +298,7 @@ class WalletAction { this._nav.goWait(); observe(this._store, 'lndReady', () => this._nav.goHome()); } catch (err) { + this.setPassword({ password: '' }); this._notification.display({ type: 'error', msg: 'Invalid password' }); } } diff --git a/test/unit/action/wallet.spec.js b/test/unit/action/wallet.spec.js index a8584413b..e94ff0fae 100644 --- a/test/unit/action/wallet.spec.js +++ b/test/unit/action/wallet.spec.js @@ -354,13 +354,17 @@ describe('Action Wallet Unit Tests', () => { expect(nav.goHome, 'was called once'); }); - it('should display error notification on failure', async () => { + it('should display error notification on failure and clear password', async () => { + sandbox.stub(wallet, 'setPassword'); grpc.sendUnlockerCommand .withArgs('UnlockWallet') .rejects(new Error('Boom!')); await wallet.unlockWallet({ walletPassword: 'baz' }); expect(notification.display, 'was called once'); expect(nav.goWait, 'was not called'); + expect(wallet.setPassword, 'was called with', { + password: '', + }); }); }); From 017b079765e00b3bf18067d1f12104a051020861 Mon Sep 17 00:00:00 2001 From: Karl Ranna Date: Wed, 3 Oct 2018 15:51:53 +0300 Subject: [PATCH 2/2] fixup! Clear password field if incorrectly entered --- test/unit/action/wallet.spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/unit/action/wallet.spec.js b/test/unit/action/wallet.spec.js index e94ff0fae..ab51e346f 100644 --- a/test/unit/action/wallet.spec.js +++ b/test/unit/action/wallet.spec.js @@ -355,16 +355,15 @@ describe('Action Wallet Unit Tests', () => { }); it('should display error notification on failure and clear password', async () => { - sandbox.stub(wallet, 'setPassword'); + wallet.setPassword('not-empty'); + expect(store.wallet.password, 'not to be', ''); grpc.sendUnlockerCommand .withArgs('UnlockWallet') .rejects(new Error('Boom!')); await wallet.unlockWallet({ walletPassword: 'baz' }); expect(notification.display, 'was called once'); expect(nav.goWait, 'was not called'); - expect(wallet.setPassword, 'was called with', { - password: '', - }); + expect(store.wallet.password, 'to be', ''); }); });