大家好,我想将firebase上的Auth状态持久性设置为local,我正在处理flutter,但我不知道如何做到这一点,我在firebase网站上找到了这个
import { getAuth, setPersistence, signInWithEmailAndPassword, browserSessionPersistence } from "firebase/auth";
const auth = getAuth();
setPersistence(auth, browserSessionPersistence)
.then(() => {
// Existing and future Auth states are now persisted in the current
// session only. Closing the window would clear any existing state even
// if a user forgets to sign out.
// ...
// New sign-in will be persisted with session persistence.
return signInWithEmailAndPassword(auth, email, password);
})
.catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
});
但是如果有人能帮上忙的话我不知道如何在flutter上做到这一点
发布于 2021-09-20 20:53:41
根据FlutterFire documentation
在安卓和iOS等原生平台上,此行为不可配置,并且用户的身份验证状态将在应用程序重启之间在设备上持久存在。用户可以通过设备设置清除应用程序缓存的数据,这将清除存储的任何现有状态。
如果您使用Flutter作为web应用程序,默认情况下,身份验证状态存储在本地存储中。如果您想将其更改为基于会话或无持久性,您可以这样设置:
// Disable persistence on web platforms
await FirebaseAuth.instance.setPersistence(Persistence.NONE);
https://stackoverflow.com/questions/69260443
复制相似问题