[英]Linking two firebase auth methods giving me error - javascript
I am trying to link email,password Auth method to current PhoneAuth method. 我正在尝试将电子邮件,密码Auth方法链接到当前的PhoneAuth方法。
But it's giving me an error: 但这给了我一个错误:
Cannot read property 'link' of undefined
无法读取未定义的属性“链接”
Here is code: 这是代码:
import { firebaseAuth,fire, messaging } from '../../config/constants';
var credential = fire.auth.EmailAuthProvider.credential(email, password);
fire.auth.currentUser.link(credential).then(function(user) {
console.log("Account linking success", user);
}, function(error) {
console.log("Account linking error", error);
});
And in config/constants 并在config / constants中
import firebase from 'firebase'
require("firebase/firestore");
const config = {
apiKey: "AIzxxxxxxxxxxxxxxxxxxKXI",
authDomain: "payxxxxxxxxxxxxja1.firebaseapp.com",
databaseURL: "https://payxxxxxxxxxxja1.firebaseio.com",
projectId: "payxxxxxxxxxxxxja1",
storageBucket: "payxxxxxxxxxxxja1.appspot.com",
messagingSenderId: "281xxxxx5xxxxx6"
}
firebase.initializeApp(config)
export const fire = firebase
export const ref = firebase.database().ref()
export const firebaseAuth = firebase.auth
export const messaging = firebase.messaging();
Please help me through this. 请帮助我。 Thanks
谢谢
Following is what they have mentioned in there Docs. 以下是他们在文档中提到的内容。
Pass the AuthCredential object to the signed-in user's linkWithCredential method:
将AuthCredential对象传递给登录用户的linkWithCredential方法:
auth.currentUser.link(credential).then(function(user) {
console.log("Account linking success", user);
}, function(error) {
console.log("Account linking error", error);
});
And following is what resolves the problem. 以下是解决问题的方法。
auth.currentUser.linkWithCredential(credential).then(function(user) {
console.log("Account linking success", user);
}, function(error) {
console.log("Account linking error", error);
});
Simply replacing link
with linkWithCredential
made it working. 只需用
linkWithCredential
替换link
就可以了。 That is how dumb the Doc writer is. 这就是Doc编写者的愚蠢之处。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.