如何解决带有用户信息的 Firebase 电话身份验证 expo-cli
我们使用 expo-cli 和 firebase 来验证使用此 link 的用户。虽然我们可以使用 signInWithCredential() 创建用户,但我们如何存储额外的用户信息,如“是管理员”或“显示名称”以及电话号码?现在看来firebase只是添加了电话号码 下面是我的代码
//function to be called when requesting for verification code
const sendVerification = () => {
const phoneProvider = new firebase.auth.PhoneAuthProvider();
phoneProvider
.verifyPhoneNumber(phoneNumber,recaptchaVerifier.current)
.then(result=>{
console.log(`sent verification code`);
setVerificationId(result);
})
.catch(error=>{
Alert.alert(`Error sending verification code ${error}`);
});
}
//function to be called when confirming the verification code that we received
//from Firebase via SMS
const confirmCode = () => {
const credential = firebase.auth.PhoneAuthProvider.credential(verificationId,code);
firebase
.auth()
.signInWithCredential(credential)
.then((result)=>{
// create user with phone number
storeAuthenticated( JSON.stringify(result.user));
props.onAuthenticated(result.user);
}).catch(error=>{
Alert.alert(`Error confirming otp ${error}`);
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。