1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Merge pull request #937 from MetaMask/i900-forgot-password-flow

I900 forgot password flow
This commit is contained in:
Dan Finlay 2016-12-19 16:01:01 -08:00 committed by GitHub
commit ead8329877
8 changed files with 32 additions and 26 deletions

View File

@ -14,6 +14,7 @@
## 2.13.11 2016-11-23 ## 2.13.11 2016-11-23
- Add support for synchronous RPC method "eth_uninstallFilter". - Add support for synchronous RPC method "eth_uninstallFilter".
- Forgotten password prompts now send users directly to seed word restoration.
## 2.13.10 2016-11-22 ## 2.13.10 2016-11-22

View File

@ -73,7 +73,7 @@ module.exports = class KeyringController extends EventEmitter {
// or accept a state-resolving promise to consume their results. // or accept a state-resolving promise to consume their results.
// //
// Not all methods end with this, that might be a nice refactor. // Not all methods end with this, that might be a nice refactor.
fullUpdate() { fullUpdate () {
this.emit('update') this.emit('update')
return Promise.resolve(this.getState()) return Promise.resolve(this.getState())
} }
@ -586,7 +586,6 @@ module.exports = class KeyringController extends EventEmitter {
// Attempts to sign the provided @object msgParams. // Attempts to sign the provided @object msgParams.
signMessage (msgParams, cb) { signMessage (msgParams, cb) {
try { try {
const msgId = msgParams.metamaskId const msgId = msgParams.metamaskId
delete msgParams.metamaskId delete msgParams.metamaskId
const approvalCb = this._unconfMsgCbs[msgId] || noop const approvalCb = this._unconfMsgCbs[msgId] || noop

View File

@ -258,7 +258,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone
function estimateGas (cb) { function estimateGas (cb) {
var estimationParams = extend(txParams) var estimationParams = extend(txParams)
query.getBlockByNumber('latest', true, function(err, block){ query.getBlockByNumber('latest', true, function (err, block) {
if (err) return cb(err) if (err) return cb(err)
// check if gasLimit is already specified // check if gasLimit is already specified
const gasLimitSpecified = Boolean(txParams.gas) const gasLimitSpecified = Boolean(txParams.gas)
@ -267,7 +267,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone
estimationParams.gas = block.gasLimit estimationParams.gas = block.gasLimit
} }
// run tx, see if it will OOG // run tx, see if it will OOG
query.estimateGas(estimationParams, function(err, estimatedGasHex){ query.estimateGas(estimationParams, function (err, estimatedGasHex) {
if (err) return cb(err.message || err) if (err) return cb(err.message || err)
// all gas used - must be an error // all gas used - must be an error
if (estimatedGasHex === estimationParams.gas) { if (estimatedGasHex === estimationParams.gas) {

View File

@ -26,6 +26,8 @@ var actions = {
CREATE_NEW_VAULT_IN_PROGRESS: 'CREATE_NEW_VAULT_IN_PROGRESS', CREATE_NEW_VAULT_IN_PROGRESS: 'CREATE_NEW_VAULT_IN_PROGRESS',
SHOW_CREATE_VAULT: 'SHOW_CREATE_VAULT', SHOW_CREATE_VAULT: 'SHOW_CREATE_VAULT',
SHOW_RESTORE_VAULT: 'SHOW_RESTORE_VAULT', SHOW_RESTORE_VAULT: 'SHOW_RESTORE_VAULT',
FORGOT_PASSWORD: 'FORGOT_PASSWORD',
forgotPassword: forgotPassword,
SHOW_INIT_MENU: 'SHOW_INIT_MENU', SHOW_INIT_MENU: 'SHOW_INIT_MENU',
SHOW_NEW_VAULT_SEED: 'SHOW_NEW_VAULT_SEED', SHOW_NEW_VAULT_SEED: 'SHOW_NEW_VAULT_SEED',
SHOW_INFO_PAGE: 'SHOW_INFO_PAGE', SHOW_INFO_PAGE: 'SHOW_INFO_PAGE',
@ -184,13 +186,13 @@ function tryUnlockMetamask (password) {
} }
} }
function transitionForward() { function transitionForward () {
return { return {
type: this.TRANSITION_FORWARD, type: this.TRANSITION_FORWARD,
} }
} }
function transitionBackward() { function transitionBackward () {
return { return {
type: this.TRANSITION_BACKWARD, type: this.TRANSITION_BACKWARD,
} }
@ -387,6 +389,12 @@ function showRestoreVault () {
} }
} }
function forgotPassword () {
return {
type: actions.FORGOT_PASSWORD,
}
}
function showInitializeMenu () { function showInitializeMenu () {
return { return {
type: actions.SHOW_INIT_MENU, type: actions.SHOW_INIT_MENU,

View File

@ -21,7 +21,6 @@ function mapStateToProps (state) {
// state from plugin // state from plugin
currentView: state.appState.currentView, currentView: state.appState.currentView,
warning: state.appState.warning, warning: state.appState.warning,
forgottenPassword: state.metamask.isInitialized,
} }
} }
@ -118,17 +117,6 @@ InitializeMenuScreen.prototype.renderMenu = function (state) {
}, },
}, 'Create'), }, 'Create'),
state.forgottenPassword ? h('.flex-row.flex-center.flex-grow', [
h('p.pointer', {
onClick: this.backToUnlockView.bind(this),
style: {
fontSize: '0.8em',
color: 'rgb(247, 134, 28)',
textDecoration: 'underline',
},
}, 'Return to Login'),
]) : null,
h('.flex-row.flex-center.flex-grow', [ h('.flex-row.flex-center.flex-grow', [
h('p.pointer', { h('p.pointer', {
onClick: this.showRestoreVault.bind(this), onClick: this.showRestoreVault.bind(this),
@ -159,10 +147,6 @@ InitializeMenuScreen.prototype.showRestoreVault = function () {
this.props.dispatch(actions.showRestoreVault()) this.props.dispatch(actions.showRestoreVault())
} }
InitializeMenuScreen.prototype.backToUnlockView = function () {
this.props.dispatch(actions.backToUnlockView())
}
InitializeMenuScreen.prototype.createNewVaultAndKeychain = function () { InitializeMenuScreen.prototype.createNewVaultAndKeychain = function () {
var passwordBox = document.getElementById('password-box') var passwordBox = document.getElementById('password-box')
var password = passwordBox.value var password = passwordBox.value

View File

@ -14,6 +14,7 @@ function RestoreVaultScreen () {
function mapStateToProps (state) { function mapStateToProps (state) {
return { return {
warning: state.appState.warning, warning: state.appState.warning,
forgottenPassword: state.appState.forgottenPassword,
} }
} }
@ -100,14 +101,17 @@ RestoreVaultScreen.prototype.render = function () {
}, 'OK'), }, 'OK'),
]), ]),
]) ])
) )
} }
RestoreVaultScreen.prototype.showInitializeMenu = function () { RestoreVaultScreen.prototype.showInitializeMenu = function () {
if (this.props.forgottenPassword) {
this.props.dispatch(actions.backToUnlockView())
} else {
this.props.dispatch(actions.showInitializeMenu()) this.props.dispatch(actions.showInitializeMenu())
}
} }
RestoreVaultScreen.prototype.createOnEnter = function (event) { RestoreVaultScreen.prototype.createOnEnter = function (event) {

View File

@ -72,6 +72,16 @@ function reduceApp (state, action) {
name: 'restoreVault', name: 'restoreVault',
}, },
transForward: true, transForward: true,
forgottenPassword: true,
})
case actions.FORGOT_PASSWORD:
return extend(appState, {
currentView: {
name: 'restoreVault',
},
transForward: false,
forgottenPassword: true,
}) })
case actions.SHOW_INIT_MENU: case actions.SHOW_INIT_MENU:
@ -169,7 +179,7 @@ function reduceApp (state, action) {
return extend(appState, { return extend(appState, {
warning: null, warning: null,
transForward: true, transForward: true,
forgottenPassword: !appState.forgottenPassword, forgottenPassword: false,
currentView: { currentView: {
name: 'UnlockScreen', name: 'UnlockScreen',
}, },

View File

@ -70,7 +70,7 @@ UnlockScreen.prototype.render = function () {
h('.flex-row.flex-center.flex-grow', [ h('.flex-row.flex-center.flex-grow', [
h('p.pointer', { h('p.pointer', {
onClick: () => this.props.dispatch(actions.goBackToInitView()), onClick: () => this.props.dispatch(actions.forgotPassword()),
style: { style: {
fontSize: '0.8em', fontSize: '0.8em',
color: 'rgb(247, 134, 28)', color: 'rgb(247, 134, 28)',