即使删除了firebase用户帐户,如何保留用户数据?

chy5wohz  于 2023-01-27  发布在  其他
关注(0)|答案(1)|浏览(160)

我使用flutter_blocfirebase来表示phone auth
我面临着这种奇怪的行为在哪里,当我手动删除user帐户,并重新启动应用程序,Firebase.instance.currentUser仍然存在,从以前的登录!!!
如何克服这一点!

class AuthCubit extends Cubit<AuthState> {
  final FirebaseAuth _auth = FirebaseAuth.instance;
  // Firebase
  AuthCubit() : super(AuthInitialState()) {
    User? currentUser = _auth.currentUser;

    print("The current user is $currentUser");
    print("the current user's uid is : ${currentUser?.uid}");
    print("The current user is ${currentUser?.phoneNumber}");
   
  }

这将生成以下输出:

I/flutter (11633): The current user is User(displayName: , email: , emailVerified: false, isAnonymous: false, metadata: UserMetadata(creationTime: 2023-01-21 06:10:04.712Z, lastSignInTime: 2023-01-21 06:10:04.713Z), phoneNumber: +919535334951, photoURL: null, providerData, [UserInfo(displayName: , email: , phoneNumber: +91XXXXXXXX, photoURL: null, providerId: phone, uid: )], refreshToken: , tenantId: null, uid: JhSqO5pZsMbp3vgZA6s1WqjKTU63)
I/flutter (11633): the current user's uid is : JhSqO5pZsMbp3vgZA6s1WqjKTU63
I/flutter (11633): The current user is +91XXXXXXXX

我的firebase auth部分看起来像:
enter image description here

xdyibdwo

xdyibdwo1#

你可能使用的iPhone将用户会话存储在它自己的密钥库中(与应用程序无关),所以删除应用程序/应用程序数据并不会清除会话。
不幸的是,唯一的方法是在应用程序启动时添加一行代码来注销用户,然后将其删除。

相关问题