В настоящее время я использую firebase для отправки OTP для проверки номера телефона клиента. Единственный функционал - отправлять пользователю смс. Основная база данных не имеет связи с firebase . Я просто вызываю функцию signInWithPhoneNumber
для отправки OTP.
Вопрос в том, есть ли какой-либо недостаток в этом? Это также не дает мне действительной возможности отправить сообщение пользователю, если он не получил первое сообщение вовремя. Также, когда мне выйти из использования firefaser? Я не нашел ни одного действующего ресурса по этому поводу. Любая помощь будет принята с благодарностью.
Так я отправляю пользователю OTP.
sendOTP = async (phone) => {
const verifier = window.recaptchaVerifier;
firebaseAuth.signInWithPhoneNumber(phone, verifier)
.then(async (confirmationResult) => {
// SMS sent. Prompt user to type the code from the message, then sign the
// user in with confirmationResult.confirm(code).
await this.setState({
confirmationResult: confirmationResult,
});
this.props.setLoaderStatus(false);
}).catch((error) => {
// Error; SMS not sent
// ...
this.props.setLoaderStatus(false);
//console.log(error);
this.setState({
serverError: true,
})
});
};
<Container>
....
<div id='recaptcha-container' />
</Container>
И вот так я проверяю, верен ли код подтверждения.
handleSubmit=(event)=> {
event.preventDefault();
this.props.confirmationResult.confirm(this.state.verificationCode).then( result => {
result.user.getIdToken().then((result) =>{
let token = result;
this.props.setUserField('access_token', token);
this.props.handleSignup();
});
this.props.setLoaderStatus(false);
}).catch((error) => {
console.log(error);
});
};