我正在使用Cordova插件cordova-plugin-firebase-authentication
进行的移动验证身份验证。插件工作正常,我可以登录,注销所有内容,这在他们的文档中已定义。
[使用此插件,我正在将Firebase JS-SDK
用于Firestore,由于我正在使用第三方身份验证机制,因此定义的Firebase onAuthStateChanged
无法正常工作,这很明显,因此onAuthStateChanged
为身份验证用户提供了null
。
我想将cordova-plugin-firebase-authentication
身份验证用户转换为firebase
js-sdk
身份验证用户,或者如何在Firebase安全规则中使用cordova-plugin-firebase-authentication
身份验证用户request.auth.uid
。
仅将cordova-plugin-firebase-authentication
用于通过给定方法发送OTP
cordova.plugins.firebase.auth
.verifyPhoneNumber("+123456789", 30000)
.then(function(verificationId) {
// pass verificationId to signInWithVerificationId
});
而不是使用cordova-plugin-firebase-authentication
cordova.plugins.firebase.auth.signInWithVerificationId("djgfioerjg34", "123456");
进行OTP验证,请使用firebase-js-sdk
方法:
var credential = firebase.auth.PhoneAuthProvider.credential(verificationIdGeneratedByCordovaPlugin, OTP);
然后,您可以使用凭据登录用户:
firebase.auth().signInWithCredential(credential);