Skip to content

Instantly share code, notes, and snippets.

@EhsanHadid
Last active February 23, 2023 09:04
Show Gist options
  • Save EhsanHadid/22e8023a67bb86cc842f0ab26450f1ea to your computer and use it in GitHub Desktop.
Save EhsanHadid/22e8023a67bb86cc842f0ab26450f1ea to your computer and use it in GitHub Desktop.
sendVerificationCode
const sendVerificationCode = async () => {
setLoading(true);
try {
const email = convertPhoneToEmail(phoneNumber);
const providers = await fetchSignInMethodsForEmail(auth, email);
if (providers.length == 0) {
const confirmationResult = await signInWithPhoneNumber(
auth,
phoneNumber,
new RecaptchaVerifier("recaptcha-container", {}, auth)
);
codeSent(confirmationResult.verificationId);
} else {
// TODO : Show there is an account and try login instead
console.log("account exist");
}
} catch (error) {
console.log(error);
} finally {
setLoading(false);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment