Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Disallow pasting recovery phrases on first run (#6602)
Browse files Browse the repository at this point in the history
* Fix disallowing paste of recovery phrase on first run, ref #6581

* Allow the leader of CATS pasting recovery phrases.
  • Loading branch information
5chdn authored and gavofyork committed Oct 3, 2017
1 parent 931a7a2 commit 41c3b05
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions js/src/modals/CreateAccount/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -310,6 +311,10 @@ export default class Store {
this.stage--;
}

@action setIsTest = isTest => {
this.isTest = isTest;
}

createAccount = (vaultStore) => {
if (!this.canCreate) {
return false;
Expand Down
14 changes: 11 additions & 3 deletions js/src/modals/FirstRun/firstRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -348,9 +355,10 @@ class FirstRun extends Component {

function mapStateToProps (state) {
const { hasAccounts } = state.personal;
const { isTest } = state.nodeStatus;

return {
hasAccounts
hasAccounts, isTest
};
}

Expand Down
3 changes: 3 additions & 0 deletions js/src/modals/FirstRun/firstRun.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function createRedux () {
return {
personal: {
hasAccounts: false
},
nodeStatus: {
isTest: false
}
};
}
Expand Down
5 changes: 4 additions & 1 deletion js/src/ui/Form/Input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 41c3b05

Please sign in to comment.