Last active
June 4, 2018 10:12
-
-
Save morloy/fdf358083863afcad842dab3b45b2fc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Accounts } from 'meteor/accounts-base'; | |
class LoginForm extends React.Component { | |
state = { | |
email: '', | |
password: '', | |
token: '', | |
requiresTwoFactor: false, | |
loading: false, | |
}; | |
onSubmit = () => { | |
this.setState({ loading: true }); | |
const { email, password, token } = this.state; | |
Accounts.callLoginMethod({ | |
methodArguments: [{ | |
user: { email }, | |
twoFactorPassword: Accounts._hashPassword(password), | |
twoFactorToken: token ? Number(token) : null, | |
}], | |
userCallback: e => e && ( | |
e.error === 'two-factor-required' ? | |
this.setState({ requiresTwoFactor: true, loading: false }) : | |
throw e, | |
}); | |
}; | |
render = () => (…) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment