Disallow pasting recovery phrases on first run (#6602)

* Fix disallowing paste of recovery phrase on first run, ref #6581

* Allow the leader of CATS pasting recovery phrases.
This commit is contained in:
Afri Schoedon 2017-10-03 10:03:24 +02:00 committed by Gav Wood
parent 931a7a2210
commit 41c3b05a20
4 changed files with 23 additions and 4 deletions

View File

@ -35,6 +35,7 @@ export default class Store {
@observable gethAddresses = [];
@observable gethImported = [];
@observable isBusy = false;
@observable isTest = false;
@observable isWindowsPhrase = false;
@observable name = '';
@observable nameError = ERRORS.noName;
@ -310,6 +311,10 @@ export default class Store {
this.stage--;
}
@action setIsTest = isTest => {
this.isTest = isTest;
}
createAccount = (vaultStore) => {
if (!this.canCreate) {
return false;

View File

@ -78,16 +78,23 @@ class FirstRun extends Component {
hasAccounts: PropTypes.bool.isRequired,
newError: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
visible: PropTypes.bool.isRequired
visible: PropTypes.bool.isRequired,
isTest: PropTypes.bool.isRequired
}
createStore = new CreateStore(this.context.api, {}, true, false);
createStore = new CreateStore(this.context.api, {}, this.props.isTest, false);
state = {
stage: 0,
hasAcceptedTnc: false
}
componentWillReceiveProps (nextProps) {
if (nextProps.isTest !== this.props.isTest) {
this.createStore.setIsTest(nextProps.isTest);
}
}
render () {
const { visible } = this.props;
const { stage } = this.state;
@ -348,9 +355,10 @@ class FirstRun extends Component {
function mapStateToProps (state) {
const { hasAccounts } = state.personal;
const { isTest } = state.nodeStatus;
return {
hasAccounts
hasAccounts, isTest
};
}

View File

@ -35,6 +35,9 @@ function createRedux () {
return {
personal: {
hasAccounts: false
},
nodeStatus: {
isTest: false
}
};
}

View File

@ -18,6 +18,7 @@ import React, { Component, PropTypes } from 'react';
import { TextField } from 'material-ui';
import { noop } from 'lodash';
import keycode from 'keycode';
import localStore from 'store';
import { nodeOrStringProptype } from '~/util/proptypes';
import { toString } from '~/util/messages';
@ -223,7 +224,9 @@ export default class Input extends Component {
}
onChange = (event, value) => {
if (!this.props.allowPaste) {
const isDev = localStore.get('allYourBaseAreBelongToUs') || false;
if (!this.props.allowPaste && !isDev) {
if (value.length - this.state.value.length > 8) {
return;
}