我使用手机号码登录用户,然后我希望他稍后输入电子邮件和密码。 (登录后)
我正在尝试将电子邮件,密码验证方法与当前的 PhoneAuth 方法相关联。
但它给了我一个错误:
无法读取未定义的属性“链接”
这是代码:
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);
});
在 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();
我认为fire.auth或fire.auth()
有问题由于
答案 0 :(得分:1)
link
已被删除,转而使用linkWithCredential
:https://firebase.google.com/support/release-notes/js#4.0.0
还要确保当前用户已做好准备:
firebase.auth().onAuthStateChange(user => {
if (user) {
// currentUser is not null.
} else {
// currentUser is null.
}
});