Last active
February 23, 2023 09:04
-
-
Save EhsanHadid/22e8023a67bb86cc842f0ab26450f1ea to your computer and use it in GitHub Desktop.
sendVerificationCode
This file contains hidden or 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
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