Skip to content Skip to sidebar Skip to footer

Different Permissions Firebase Auth

I always use firebase to login authentication, but this time I've a problem. My new application works with two types of users, the admin and the normal users. How can I distinguish

Solution 1:

You can use Firebase Database with an object combining Firebase UserId and Role

publicclassUser {
    publicString userId;
    publicString role;

    publicUser(String userId, String role) {
        this.username = username;
        this.email = email;
    }
}

To write :

mDatabase = FirebaseDatabase.getInstance().getReference();
privatevoidwriteNewUser(String userId, String role) {
    User user = newUser(name, role);

    mDatabase.child("users").child(userId).setValue(user);
}

Post a Comment for "Different Permissions Firebase Auth"