默认情况下,当前版本9中的Firebase/auth将会话本地存储在indexedDB中。但是在加载应用程序时,我在firebase中找不到一个方法来检索本地会话。

当应该可以检索“保存的当前用户会话”时,onAuthStateChanged需要时间来准备好身份验证。
auth.onAuthStateChanged(function (userData) {
if (userData) {
// User is signed in.
} else {
// No user is signed in.
}
});有没有办法不需要手动访问indexedDB就可以直接访问本地当前用户?而不是像在这个gist中那样转储indexedDB,或者亲自将用户发送到localStorage?
发布于 2021-06-11 20:43:04
您可能正在寻找以下内容:
import { getAuth } from "firebase/auth";
const auth = getAuth();
const user = auth.currentUser; // null if no user您可以在documentation中找到更多信息
https://stackoverflow.com/questions/67867567
复制相似问题