我一直在使用火力地堡的認證項目。當我登錄到我的項目時,有時firebase.auth().currentUser
方法返回來自其他用戶的信息。有時候我會從當前的實際用戶那裏獲得信息,有時候會從之前登錄的用戶那裏獲得信息 - 發生這種情況時,糾正問題併爲正確用戶獲取數據的唯一方法是註銷並重新登錄。火力點 - 火力地堡當前用戶不是存儲在正確的用戶
我的登錄方法:
onLoginClick =() => {
firebase.auth().signInWithEmailAndPassword(this.state.email.trim(), this.state.password.trim())
.then((user) => {
//Some redirects depending on my users role
})
.catch((error) => {
console.log(error, error.message);
if (error.code == "auth/user-not-found" || error.code == "auth/wrong-password") {
//Handle error
}
});
}
我的退出方法:
onLogoutClick =() => {
firebase.auth().signOut().then(function() {
this.props.history.replace("/")
}).catch(function (error) {
console.log(error);
});
}
他們是非常標準的,但好像我做錯了什麼。我試着在註銷方法上清除sessionStorage
和localStorage
,但這沒有幫助。
UPDATE:
我一些建議,試圖像做:
firebase.auth().signOut().then(() => {
firebase.auth().signInWithEmailAndPassword(email, password).then((user) => {
//My redirects and everything
})
})
但是,這是行不通的。
另外,我注意到,當我登錄並使用錯誤的憑據,在sessionStorage的獲取與用戶先前簽署的項目,即使我籤他。
之前您登錄檢查,如果當前用戶是零。如果它沒有呼叫您的註銷功能,請將用戶簽入。最有可能發生這種情況的原因是,舊用戶仍然登錄。您如何退出應用程序?用戶是否保持登錄狀態? – DoesData
@DoesData當我註銷用戶它;將我的應用重定向到主屏幕,所有登錄的用戶選項消失,我檢查了開發者控制檯,localStorage好像沒有當前用戶密鑰。但是,當我再次登錄時,即使我之前檢查過,有時也會得到錯誤的信息。 –