Javascript 如何使用Firebase Auth强制注销用户?
我正在尝试使用使用Firebase构建的Firebase Auth注销该应用程序。这实际上会注销用户,但无法呈现新页面,并提供以下信息:Javascript 如何使用Firebase Auth强制注销用户?,javascript,reactjs,firebase,firebase-authentication,Javascript,Reactjs,Firebase,Firebase Authentication,我正在尝试使用使用Firebase构建的Firebase Auth注销该应用程序。这实际上会注销用户,但无法呈现新页面,并提供以下信息: TypeError: Cannot read property 'push' of undefined 这是我的代码: // sign out const signOut = (history ) => { doSignOut().then(() => {props.history.push(routes.SIGN_IN)}
TypeError: Cannot read property 'push' of undefined
这是我的代码:
// sign out
const signOut = (history ) => {
doSignOut().then(() => {props.history.push(routes.SIGN_IN)})
}
//
firestore.collection('customers').doc(userID).collection('subscriptions')
.where('status', '==', 'trialing' || "active").get()
.then(activeSubscriptions => {
// if this is true, the user has no active subscription.
if (activeSubscriptions.empty === false) {
console.log("line 31")
{signOut(props.history)}
}
});
有什么想法吗?firebase.auth.signOut()有什么不管用的地方吗?比如:在那一行执行后,你看到了什么意外行为?@Frankvanpoffelen我实际上用一个更新的错误编辑了我的问题,所以它看起来像
道具。历史记录未定义。你的意思是说那是history.push(…)
而不是props.history.push(…)
?我实际上是导入了一个函数const signOut=(history)=>{doSignOut()。然后(()=>{props.history.push(routes.SIGN_IN)}
,然后在需要的地方调用这个函数,它就像一个符咒。很高兴听到@Gianluca。你可能想把它作为一个自我回答来结束这篇文章,这样其他人就可以更容易地从你将来学到的东西中获益。