Skip to content

Commit

Permalink
fix(aws-amplify-react): add hotkey to sign in
Browse files Browse the repository at this point in the history
fix(aws-amplify-react): add hotkey to sign in
  • Loading branch information
powerful23 authored Jun 13, 2018
2 parents 5a6b9be + fb36396 commit 82299c5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/aws-amplify-react/src/Auth/SignIn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,28 @@ export default class SignIn extends AuthPiece {

this.checkContact = this.checkContact.bind(this);
this.signIn = this.signIn.bind(this);
this.onKeyDown = this.onKeyDown.bind(this);

this._validAuthStates = ['signIn', 'signedOut', 'signedUp'];
this.state = {};
}

componentWillMount() {
window.addEventListener('keydown', this.onKeyDown);
}

componentWillUnmount() {
window.removeEventListener('keydown', this.onKeyDown);
}

onKeyDown(e) {
if (this.props.authState === 'signIn') {
if (e.keyCode === 13) { // when press enter
this.signIn();
}
}
}

checkContact(user) {
Auth.verifiedContact(user)
.then(data => {
Expand Down

0 comments on commit 82299c5

Please sign in to comment.