Block user in auth firebase and do not let him enter the APP

0

Good, I have a login made in Android to enter with Gmail keeping the authentication in firebase, the app enters ok and creates the authentication in fire generating the corresponding User UID. Now I see that in the options of each user I have the items reset password, disabled account and delete account. When ticking disabled, nothing happens, how can I validate if the account is enabled or disabled and, in case of disabled, do not allow login to the credentials by mistake?

    
asked by Juan 11.10.2017 в 23:16
source

1 answer

0

The validation is done by requesting the current user's token, if the user is unsubscribed, firebase returns a failed response with a string containing the string "USER_DISABLE" ... Sorry if my code is in Java 8:

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        user.getToken(true)
                .addOnCompleteListener(task -> {
                    if (task.isSuccessful()) {
                        String idToken = task.getResult().getToken();
                        // Send token to your backend via HTTPS
                        openHome();
                    }
                })
        .addOnFailureListener(e -> {
            if(e.getMessage().contains("USER_DISABLED")){
                String message = getString(R.string.user_disabled);
                logOut(message);
            }
        });

    }
    
answered by 02.11.2017 в 07:19