admin firebase storage requires user to signin everytime code example

Example 1: restrict the user from going to signup or login page if the user is already logged in firebase auth

var user = firebase.auth().currentUser;

if (user) {
  // User is signed in.
} else {
  // No user is signed in.
}

Example 2: how to check if user is logged in firebase android and then load another activity

private FirebaseAuth firebaseAuth;
 FirebaseAuth.AuthStateListener mAuthListener;
    firebaseAuth = FirebaseAuth.getInstance();

      mAuthListener = new FirebaseAuth.AuthStateListener(){
                @Override
                public  void  onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth){
            FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
        if(user!=null){
        Intent intent = new Intent(LoginActivity.this, MainActivity.class);
        startActivity(intent);
        finish();
}
                }


            };

Tags:

Misc Example