I'm transitioning from Email+Password & integrating Firebase Auth signInWithPhoneNumber into my React web app & I'm confused on how to go from:
1. submit phone #
to 2. submit code verification.
It seems to me that the firebase function .signInWithPhoneNumber wants the phone # + verification code all at once, which as we know isn't how real life works.
So, how do you implement prompting the user for the verification code?
handleSignUp = event => {
event.preventDefault();
window.appVerifier = new firebase.auth.RecaptchaVerifier(
"recaptcha-container",
{
size: "invisible"
}
);
const appVerifier = window.appVerifier;
firebase
.auth()
.signInWithPhoneNumber(this.state.phoneNumber, appVerifier)
.then(function(confirmationResult) {
console.log("Success");
// SMS sent. Prompt user to type the code from the message, then confirm
return confirmationResult.confirm(verificationId);
})
.catch(function(error) {
console.log("Error:" + error.code);
});
};
Sign up form:
<TextField
name="First name"
value={this.state.firstName}
/>
<TextField
name="lastName"
value={this.state.lastName}
/>
<TextField
name="Username"
value={this.state.handle}
/>
<TextField
name="tel"
value={this.state.phoneNumber}
/>
<TextField
name="confirm"
value={this.state.confirm}
/>
<Button
type="submit"
>
Sign Up
</Button>
Any help will be greatly appreciated!