Skip to content

Commit

Permalink
allow autocomplete username. show login errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhughes27 committed Jul 26, 2018
1 parent 145493a commit c4a1bdc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion clients/admin_next/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class Auth {
headers,
body
}).then((response) => {
return response.json();
return response.status === 201
? response.json()
: Promise.reject("Invalid username or password");
}).then((data) => {
this.setToken(data.jwt);
return Promise.resolve();
Expand Down
5 changes: 4 additions & 1 deletion clients/admin_next/src/components/App/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Props extends WithStyles<typeof styles> {
interface State {
email: string;
password: string;
error?: string;
}

class LoginForm extends React.Component<Props, State> {
Expand All @@ -38,6 +39,8 @@ class LoginForm extends React.Component<Props, State> {

auth.login(this.state.email, this.state.password).then(() => {
this.props.onComplete();
}).catch((error) => {
this.setState({error});
});
}

Expand All @@ -64,10 +67,10 @@ class LoginForm extends React.Component<Props, State> {
name="email"
label="Username"
margin="normal"
autoComplete="off"
fullWidth
value={this.state.email}
onChange={this.handleChange}
helperText={this.state.error}
/>

<TextField
Expand Down

0 comments on commit c4a1bdc

Please sign in to comment.