aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/scripts/lib/config-manager.js11
-rw-r--r--app/scripts/metamask-controller.js15
-rw-r--r--ui/app/actions.js24
-rw-r--r--ui/app/app.js22
-rw-r--r--ui/app/keychains/hd/restore-vault.js4
-rw-r--r--ui/app/main-container.js8
-rw-r--r--ui/app/unlock.js5
7 files changed, 65 insertions, 24 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index 9c0dffe9c..34b603b96 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -42,6 +42,17 @@ ConfigManager.prototype.getData = function () {
return this.store.getState()
}
+ConfigManager.prototype.setPasswordForgotten = function (passwordForgottenState) {
+ const data = this.getData()
+ data.forgottenPassword = passwordForgottenState
+ this.setData(data)
+}
+
+ConfigManager.prototype.getPasswordForgotten = function (passwordForgottenState) {
+ const data = this.getData()
+ return data.forgottenPassword
+}
+
ConfigManager.prototype.setWallet = function (wallet) {
var data = this.getData()
data.wallet = wallet
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 962516af6..cb671ec3c 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -315,6 +315,7 @@ module.exports = class MetamaskController extends EventEmitter {
{
lostAccounts: this.configManager.getLostAccounts(),
seedWords: this.configManager.getSeedWords(),
+ forgottenPassword: this.configManager.getPasswordForgotten(),
}
)
}
@@ -337,6 +338,8 @@ module.exports = class MetamaskController extends EventEmitter {
setCurrentCurrency: this.setCurrentCurrency.bind(this),
setUseBlockie: this.setUseBlockie.bind(this),
markAccountsFound: this.markAccountsFound.bind(this),
+ markPasswordForgotten: this.markPasswordForgotten.bind(this),
+ unMarkPasswordForgotten: this.unMarkPasswordForgotten.bind(this),
// coinbase
buyEth: this.buyEth.bind(this),
@@ -791,6 +794,18 @@ module.exports = class MetamaskController extends EventEmitter {
cb(null, this.getState())
}
+ markPasswordForgotten(cb) {
+ this.configManager.setPasswordForgotten(true)
+ this.sendUpdate()
+ cb()
+ }
+
+ unMarkPasswordForgotten(cb) {
+ this.configManager.setPasswordForgotten(false)
+ this.sendUpdate()
+ cb()
+ }
+
restoreOldVaultAccounts (migratorOutput) {
const { serialized } = migratorOutput
return this.keyringController.restoreKeyring(serialized)
diff --git a/ui/app/actions.js b/ui/app/actions.js
index c52b3cf93..d0436ad21 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -47,6 +47,8 @@ var actions = {
SHOW_RESTORE_VAULT: 'SHOW_RESTORE_VAULT',
FORGOT_PASSWORD: 'FORGOT_PASSWORD',
forgotPassword: forgotPassword,
+ markPasswordForgotten,
+ unMarkPasswordForgotten,
SHOW_INIT_MENU: 'SHOW_INIT_MENU',
SHOW_NEW_VAULT_SEED: 'SHOW_NEW_VAULT_SEED',
SHOW_INFO_PAGE: 'SHOW_INFO_PAGE',
@@ -819,6 +821,28 @@ function showRestoreVault () {
}
}
+function markPasswordForgotten () {
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+ return background.markPasswordForgotten(() => {
+ dispatch(actions.hideLoadingIndication())
+ dispatch(actions.forgotPassword())
+ forceUpdateMetamaskState(dispatch)
+ })
+ }
+}
+
+function unMarkPasswordForgotten () {
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+ return background.unMarkPasswordForgotten(() => {
+ dispatch(actions.hideLoadingIndication())
+ dispatch(actions.forgotPassword())
+ forceUpdateMetamaskState(dispatch)
+ })
+ }
+}
+
function forgotPassword () {
return {
type: actions.FORGOT_PASSWORD,
diff --git a/ui/app/app.js b/ui/app/app.js
index df9eab03c..20dc65df3 100644
--- a/ui/app/app.js
+++ b/ui/app/app.js
@@ -80,7 +80,7 @@ function mapStateToProps (state) {
menuOpen: state.appState.menuOpen,
network: state.metamask.network,
provider: state.metamask.provider,
- forgottenPassword: state.appState.forgottenPassword,
+ forgottenPassword: state.metamask.forgottenPassword,
lastUnreadNotice: state.metamask.lastUnreadNotice,
lostAccounts: state.metamask.lostAccounts,
frequentRpcList: state.metamask.frequentRpcList || [],
@@ -358,20 +358,12 @@ App.prototype.renderPrimary = function () {
})
}
- // show initialize screen
- if (!props.isInitialized || props.forgottenPassword) {
- // show current view
- log.debug('rendering an initialize screen')
- switch (props.currentView.name) {
-
- case 'restoreVault':
- log.debug('rendering restore vault screen')
- return h(HDRestoreVaultScreen, {key: 'HDRestoreVaultScreen'})
-
- default:
- log.debug('rendering menu screen')
- return h(InitializeMenuScreen, {key: 'menuScreenInit'})
- }
+ if (props.isInitialized && props.forgottenPassword) {
+ log.debug('rendering restore vault screen')
+ return h(HDRestoreVaultScreen, {key: 'HDRestoreVaultScreen'})
+ } else if (!props.isInitialized) {
+ log.debug('rendering menu screen')
+ return h(InitializeMenuScreen, {key: 'menuScreenInit'})
}
// show unlock screen
diff --git a/ui/app/keychains/hd/restore-vault.js b/ui/app/keychains/hd/restore-vault.js
index 24b37a83d..a4ed137f9 100644
--- a/ui/app/keychains/hd/restore-vault.js
+++ b/ui/app/keychains/hd/restore-vault.js
@@ -107,6 +107,7 @@ RestoreVaultScreen.prototype.render = function () {
}
RestoreVaultScreen.prototype.showInitializeMenu = function () {
+ this.props.dispatch(actions.unMarkPasswordForgotten())
if (this.props.forgottenPassword) {
this.props.dispatch(actions.backToUnlockView())
} else {
@@ -149,6 +150,9 @@ RestoreVaultScreen.prototype.createNewVaultAndRestore = function () {
this.warning = null
this.props.dispatch(actions.displayWarning(this.warning))
this.props.dispatch(actions.createNewVaultAndRestore(password, seed))
+ .then(() => {
+ this.props.dispatch(actions.unMarkPasswordForgotten())
+ })
.catch((err) => {
log.error(err.message)
})
diff --git a/ui/app/main-container.js b/ui/app/main-container.js
index 031f61e84..292abcc3d 100644
--- a/ui/app/main-container.js
+++ b/ui/app/main-container.js
@@ -2,7 +2,6 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const AccountAndTransactionDetails = require('./account-and-transaction-details')
-const HDRestoreVaultScreen = require('./keychains/hd/restore-vault')
const Settings = require('./settings')
const UnlockScreen = require('./unlock')
@@ -28,13 +27,6 @@ MainContainer.prototype.render = function () {
if (this.props.isUnlocked === false) {
switch (this.props.currentViewName) {
- case 'restoreVault':
- log.debug('rendering restore vault screen')
- contents = {
- component: HDRestoreVaultScreen,
- key: 'HDRestoreVaultScreen',
- }
- break
case 'config':
log.debug('rendering config screen from unlock screen.')
return h(Settings, {key: 'config'})
diff --git a/ui/app/unlock.js b/ui/app/unlock.js
index ec97b03bf..e77d17d7b 100644
--- a/ui/app/unlock.js
+++ b/ui/app/unlock.js
@@ -74,7 +74,10 @@ UnlockScreen.prototype.render = function () {
h('.flex-row.flex-center.flex-grow', [
h('p.pointer', {
- onClick: () => this.props.dispatch(actions.forgotPassword()),
+ onClick: () => {
+ this.props.dispatch(actions.markPasswordForgotten())
+ global.platform.openExtensionInBrowser()
+ },
style: {
fontSize: '0.8em',
color: 'rgb(247, 134, 28)',