Skip to content

Commit

Permalink
🐛 Verify that passphrase used belongs to active account
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltomasik committed Jun 18, 2018
1 parent 0dbc73f commit edf8d46
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/signMessage/confirmMessage.js
Expand Up @@ -4,6 +4,7 @@ import styles from './confirmMessage.css';
import { Button } from '../toolbox/buttons/button';
import Input from '../toolbox/inputs/input';
import { passphraseIsValid } from '../../utils/form';
import { extractPublicKey } from '../../utils/account';
// eslint-disable-next-line import/no-named-as-default
import PassphraseInput from '../passphraseInput';
import TransitionWrapper from '../toolbox/transitionWrapper';
Expand Down Expand Up @@ -31,6 +32,18 @@ class ConfirmMessage extends React.Component {
}

handleChange(name, value, error) {
if (!error) {
const publicKeyMap = {
passphrase: 'publicKey',
secondPassphrase: 'secondPublicKey',
};

const expectedPublicKey = this.props.account[publicKeyMap[name]];

if (expectedPublicKey && expectedPublicKey !== extractPublicKey(value)) {
error = this.props.t('Entered passphrase does not belong to the active account');
}
}
this.setState({
[name]: {
value,
Expand Down

0 comments on commit edf8d46

Please sign in to comment.