add error text for incorrect password

This commit is contained in:
Barry Gitarts 2018-11-19 12:54:22 -05:00
parent d22467a916
commit e000c53ac6
2 changed files with 14 additions and 7 deletions

View File

@ -74,13 +74,17 @@ export default class Home extends PureComponent<Props> {
} }
setupKeyringController = async (password, mnemonic) => { setupKeyringController = async (password, mnemonic) => {
this.setState({ loading: true });
const { keyStore } = this.state; const { keyStore } = this.state;
if (!keyStore) { if (!keyStore) {
this.keyringController = await createVault(password, mnemonic); this.keyringController = await createVault(password, mnemonic);
} else { } else {
try {
this.keyringController = await restoreVault(password); this.keyringController = await restoreVault(password);
} catch(err) {
throw err;
} }
}
this.setState({ loading: true });
const accounts = await this.keyringController.getAccounts(); const accounts = await this.keyringController.getAccounts();
this.connect(accounts[0]); this.connect(accounts[0]);
} }

View File

@ -24,16 +24,18 @@ const Login = ({ setupKeyringController, keyStore, wipeKeyStore, connect }) => (
> >
<Formik <Formik
initialValues={{ password: '', seed: '' }} initialValues={{ password: '', seed: '' }}
onSubmit={(values, { resetForm }) => { onSubmit={(values, { resetForm, setFieldError }) => {
const { password, seed } = values; const { password, seed } = values;
setupKeyringController(password, seed); setupKeyringController(password, seed)
.catch(err => {
setFieldError("password", err.message)
});
resetForm(); resetForm();
}} }}
> >
{({ {({
values, values,
errors, errors,
touched,
handleChange, handleChange,
handleBlur, handleBlur,
handleSubmit handleSubmit
@ -60,11 +62,12 @@ const Login = ({ setupKeyringController, keyStore, wipeKeyStore, connect }) => (
label={isNull(keyStore) ? "Set your password" : "Enter your password to login"} label={isNull(keyStore) ? "Set your password" : "Enter your password to login"}
variant="outlined" variant="outlined"
fullWidth fullWidth
error={errors.password}
helperText={errors.password}
value={values.password} value={values.password}
onBlur={handleBlur} onBlur={handleBlur}
onChange={handleChange} onChange={handleChange}
/> />
{errors.password && touched.password && errors.password}
<Button size="large" variant="outlined" color="primary" onClick={() => connect()}> <Button size="large" variant="outlined" color="primary" onClick={() => connect()}>
USE A ONE TIME RANDOM ACCOUNT USE A ONE TIME RANDOM ACCOUNT
</Button> </Button>