FirebaseAuth.getInstance().getCurrentUser() returns previously logged out user

徘徊边缘 提交于 2019-12-12 00:06:36

问题


I have Android app which uses FirebaseAuth and FirebaseDatabase functionalities. Everything was working fine.

During last week I was working with one user (user 1) as an admin of the app and yesterday I registered another user (user 2) as a normal user(not admin).

Since all my admin functionalities were working fine, I never logged in as the user 1 again. However I had to uninstall my app today and by that time I was logged in as user 2.

When I reinstalled it again, I was automatically logged in as user 1 for some reason. So I logged out and logged in as user 2 again and uninstalled again. The same thing happened again and again.

I checked the user ID I am getting from the FirebaseAuth and its the user 1's user ID which I had logged out previously.

FirebaseAuth auth = FirebaseAuth.getInstance();
if(auth !=null)
{
    String uid = auth.getCurrentUser.getUid();
}

Please help me to solve this issue and I have added my logged out code below.

 AuthUI.getInstance()
    .signOut(ShopHome.this)
    .addOnCompleteListener(new OnCompleteListener<Void>() {
        public void onComplete(@NonNull Task<Void> task) {
           // Code for login Activity              
         }
    });

回答1:


You are using FirebaseUI-Android which uses Smart Lock to automatically log you in, even after after an uninstall of the app. If you do not want to automatically log-in, you can disable automatic sign in with Smart Lock.




回答2:


Make a new emulator with a different device. This is the way I bypassed this issue.



来源:https://stackoverflow.com/questions/37887007/firebaseauth-getinstance-getcurrentuser-returns-previously-logged-out-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!