From f5105293bf2d3e6fb325e015b5b2b67baa7d03cc Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 31 Mar 2016 10:47:40 -0700 Subject: Do not cache the seed, retrieve it from the decrypted wallet --- app/scripts/lib/idStore.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'app/scripts/lib/idStore.js') diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index f8267f6ca..1bc1ebcb2 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -45,11 +45,13 @@ IdentityStore.prototype.createNewVault = function(password, entropy, cb){ configManager.clearWallet() this._createIdmgmt(password, null, entropy, (err) => { if (err) return cb(err) - var seedWords = this._idmgmt.getSeed() - configManager.setSeedWords(seedWords) + this._loadIdentities() this._didUpdate() this._autoFaucet() + + configManager.setShowSeedWords(true) + var seedWords = this._idmgmt.getSeed() cb(null, seedWords) }) } @@ -69,20 +71,28 @@ IdentityStore.prototype.setStore = function(store){ } IdentityStore.prototype.clearSeedWordCache = function(cb) { - configManager.clearSeedWords() + configManager.setShowSeedWords(false) cb() } IdentityStore.prototype.getState = function(){ - const cachedSeeds = configManager.getSeedWords() + var seedWords = this.getSeedIfUnlocked() var wallet = configManager.getWallet() return clone(extend(this._currentState, { - isInitialized: !!configManager.getWallet() && !cachedSeeds, + isInitialized: !!configManager.getWallet() && !seedWords, isUnlocked: this._isUnlocked(), - seedWords: cachedSeeds, + seedWords: seedWords, })) } +IdentityStore.prototype.getSeedIfUnlocked = function() { + var showSeed = configManager.getShouldShowSeedWords() + var idmgmt = this._idmgmt + var shouldShow = showSeed && !!idmgmt + var seedWords = shouldShow ? idmgmt.getSeed() : null + return seedWords +} + IdentityStore.prototype.getSelectedAddress = function(){ return this._currentState.selectedAddress } -- cgit