Add a password strength component (#4153)

* Added new PasswordStrength Component

* Added tests

* PR Grumbles
This commit is contained in:
Nicolas Gotchac
2017-01-13 15:52:42 +01:00
committed by Jaco Greeff
parent 57ce845e4c
commit 4a714d4a3e
10 changed files with 282 additions and 33 deletions

View File

@@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react';
import IconButton from 'material-ui/IconButton';
import { IconButton } from 'material-ui';
import { RadioButton, RadioButtonGroup } from 'material-ui/RadioButton';
import ActionAutorenew from 'material-ui/svg-icons/action/autorenew';

View File

@@ -88,12 +88,13 @@ export default class RecoveryPhrase extends Component {
value={ password2 }
onChange={ this.onEditPassword2 } />
</div>
<Checkbox
className={ styles.checkbox }
label='Key was created with Parity <1.4.5 on Windows'
checked={ windowsPhrase }
onCheck={ this.onToggleWindowsPhrase } />
</div>
<Checkbox
className={ styles.checkbox }
label='Key was created with Parity <1.4.5 on Windows'
checked={ windowsPhrase }
onCheck={ this.onToggleWindowsPhrase }
/>
</Form>
);
}

View File

@@ -16,6 +16,7 @@
import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';
import ActionDone from 'material-ui/svg-icons/action/done';
import ActionDoneAll from 'material-ui/svg-icons/action/done-all';
import ContentClear from 'material-ui/svg-icons/content/clear';
@@ -100,44 +101,45 @@ export default class CreateAccount extends Component {
switch (stage) {
case 0:
return (
<CreationType
onChange={ this.onChangeType } />
<CreationType onChange={ this.onChangeType } />
);
case 1:
if (createType === 'fromNew') {
return (
<NewAccount
onChange={ this.onChangeDetails } />
<NewAccount onChange={ this.onChangeDetails } />
);
} else if (createType === 'fromGeth') {
}
if (createType === 'fromGeth') {
return (
<NewGeth
accounts={ accounts }
onChange={ this.onChangeGeth } />
onChange={ this.onChangeGeth }
/>
);
} else if (createType === 'fromPhrase') {
}
if (createType === 'fromPhrase') {
return (
<RecoveryPhrase
onChange={ this.onChangeDetails } />
<RecoveryPhrase onChange={ this.onChangeDetails } />
);
} else if (createType === 'fromRaw') {
}
if (createType === 'fromRaw') {
return (
<RawKey
onChange={ this.onChangeDetails } />
<RawKey onChange={ this.onChangeDetails } />
);
}
return (
<NewImport
onChange={ this.onChangeWallet } />
<NewImport onChange={ this.onChangeWallet } />
);
case 2:
if (createType === 'fromGeth') {
return (
<AccountDetailsGeth
addresses={ this.state.gethAddresses } />
<AccountDetailsGeth addresses={ this.state.gethAddresses } />
);
}
@@ -145,7 +147,8 @@ export default class CreateAccount extends Component {
<AccountDetails
address={ this.state.address }
name={ this.state.name }
phrase={ this.state.phrase } />
phrase={ this.state.phrase }
/>
);
}
}
@@ -210,11 +213,14 @@ export default class CreateAccount extends Component {
}
return (
<Warning warning={
<FormattedMessage
id='createAccount.warning.insecurePassword'
defaultMessage='It is recommended that a strong password be used to secure your accounts. Empty and trivial passwords are a security risk.' />
} />
<Warning
warning={
<FormattedMessage
id='createAccount.warning.insecurePassword'
defaultMessage='It is recommended that a strong password be used to secure your accounts. Empty and trivial passwords are a security risk.'
/>
}
/>
);
}
@@ -371,7 +377,7 @@ export default class CreateAccount extends Component {
}
onChangeDetails = (canCreate, { name, passwordHint, address, password, phrase, rawKey, windowsPhrase }) => {
this.setState({
const nextState = {
canCreate,
name,
passwordHint,
@@ -380,7 +386,9 @@ export default class CreateAccount extends Component {
phrase,
windowsPhrase: windowsPhrase || false,
rawKey
});
};
this.setState(nextState);
}
onChangeRaw = (canCreate, rawKey) => {

View File

@@ -23,7 +23,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { newError, openSnackbar } from '~/redux/actions';
import { Button, Modal, IdentityName, IdentityIcon } from '~/ui';
import { Button, Modal, IdentityName, IdentityIcon, PasswordStrength } from '~/ui';
import Form, { Input } from '~/ui/Form';
import { CancelIcon, CheckIcon, SendIcon } from '~/ui/Icons';
@@ -120,7 +120,7 @@ class PasswordManager extends Component {
}
renderPage () {
const { busy, isRepeatValid, passwordHint } = this.store;
const { busy, isRepeatValid, newPassword, passwordHint } = this.store;
return (
<Tabs
@@ -236,6 +236,8 @@ class PasswordManager extends Component {
type='password' />
</div>
</div>
<PasswordStrength input={ newPassword } />
</div>
</Form>
</Tab>