Make sure there's a form so enter logs in for netlify auth

This commit is contained in:
Mathias Biilmann Christensen 2017-09-04 23:24:57 -07:00
parent afa5a9af2c
commit 30aa880ed2

View File

@ -12,7 +12,6 @@ export default class AuthenticationPage extends React.Component {
state = { username: "", password: "", errors: {} }; state = { username: "", password: "", errors: {} };
handleChange = (name, value) => { handleChange = (name, value) => {
this.setState({ ...this.state, [name]: value }); this.setState({ ...this.state, [name]: value });
}; };
@ -38,7 +37,7 @@ export default class AuthenticationPage extends React.Component {
.then((user) => { .then((user) => {
this.props.onLogin(user); this.props.onLogin(user);
}) })
.catch((error) => { .catch((error) => {
this.setState({ errors: { server: error.description || error.msg || error }, loggingIn: false }); this.setState({ errors: { server: error.description || error.msg || error }, loggingIn: false });
}); });
}; };
@ -49,36 +48,37 @@ export default class AuthenticationPage extends React.Component {
return ( return (
<section className={styles.root}> <section className={styles.root}>
<Card className={styles.card}> <Card className={styles.card}>
<img src={logo} width={100} role="presentation" /> <form onSubmit={this.handleLogin}>
{error && <p> <img src={logo} width={100} role="presentation" />
<span className={styles.errorMsg}>{error}</span> {error && <p>
</p>} <span className={styles.errorMsg}>{error}</span>
{errors.server && <p> </p>}
<span className={styles.errorMsg}>{errors.server}</span> {errors.server && <p>
</p>} <span className={styles.errorMsg}>{errors.server}</span>
<Input </p>}
type="text" <Input
label="Username" type="text"
name="username" label="Username"
value={this.state.username} name="username"
error={errors.username} value={this.state.username}
onChange={this.handleChange.bind(this, "username")} // eslint-disable-line error={errors.username}
/> onChange={this.handleChange.bind(this, "username")} // eslint-disable-line
<Input />
type="password" <Input
label="Password" type="password"
name="password" label="Password"
value={this.state.password} name="password"
error={errors.password} value={this.state.password}
onChange={this.handleChange.bind(this, "password")} // eslint-disable-line error={errors.password}
/> onChange={this.handleChange.bind(this, "password")} // eslint-disable-line
<Button />
className={styles.button} <Button
raised className={styles.button}
onClick={this.handleLogin} raised
> >
<Icon type="login" /> Login <Icon type="login" /> Login
</Button> </Button>
</form>
</Card> </Card>
</section> </section>
); );