Can i use multiple apps on a single firebase database? Will it use same auth or different auth? - firebase

I am currently developing multiple apps with Firebase and I have a doubt. I have a user and an admin. My problem is if I am using the same firebase database, will the user be able to sign up into Admin's app using his credentials or both app will have different authentication. I don't want the user logging into the admin app with user credentials. If it is possible, what can I do to avoid it?
I haven't done trying it.

Can I use multiple apps on a single Firebase database?
Yes, you can.
Will it use the same auth or a different auth?
If both apps are added to the same project, then the authentication will be the same for both projects. This means that the user can use the same account for both projects. This also means that both apps can write/read data to/from the same database.

You can solve this in multiple ways
Have a different collection to store the data of the admins and then check on the login if the email is present in the collection
With the Rules of Firestore

Related

How to differentiate firebase authenitcated users in multiple apps in same firebase project?

I have one project based on firebase in which i have multiple apps having same code but white labeled data.
All users are authenticated by firebase authentication.
Now the Problem is when one authenticated used tries to login in the one white label app it logged in sucessfully but when same users who is not registered in another white labeled app also logged in as same authentication process because of one authentication for all apps in same project in firebase.
so I want to know how to differentiate the users in same firebase project with multiple apps ?
sorry for poor english
You can use Custom Claims to track which user have access to which apps. Note that this require you to use Cloud Functions
Custom Claims documents: https://firebase.google.com/docs/auth/admin/custom-claims
Cloud Functions sample code:
admin.auth().setCustomUserClaims(uid, {whiteLabelApp1: true}).then(() => {//do something here if you want});
And for client code, just refer to the docs

How to allow user to create and switch between multiple accounts in Flutter?

I am trying to make a Flutter app where the user can sign in into multiple accounts (different email IDs) and can switch between them from the UserAccounsDrawerHeader. For example, in Gmail app, users can switch between multiple Gmail accounts. Is this possible using Firebase Auth for Flutter?
In the default scenario, Firebase Auth generally does not support allowing a user to be signed in with multiple accounts at the same time. If you want to add support, what you will have to do is use initailizeApp() to initialize a new App instance - one for each user account, and sign in the user to each one of them. You will then have to pass that app instance around to the other Firebase APIs to use that account for authenticated access (for example, Firestore queries).
To be honest, it's not clear to me from the provided APIs how to do that last part. but perhaps Firestore.getInstance(app) might do it.
In any event, it is not trivial to implement. There is not a simple configuration or trick that will allow multiple simultaneous sign-ins. Usually apps just make the user sign out, then in again with another account.

How can one fetch the authorized users along with their details in Firebase

I have a Firebase project, which I'm currently using with android. I need to programmatically fetch details of the users authorized along with the UID, Email, etc. Exactly the way it is shown in firebase (with the search), this web portal will be given to the vendor or the person using it to verify the user's authenticity.
I've attached the screenshot from Firebase, I'm hoping to replicate it the same way with the search. If this is possible, how do I go about doing this?
It's not possible to list users from an Android app, using only the Firebase Authentication SDK. You can list users using the Firebase Admin SDK, but that can only be run on a backend you control, using service account credentials for your project.
It might be easier if you store user info in a database, to be queried by client code, rather than try to have your app try to access auth data directly.

Creating and managing privileged users in Firebase via the console

Using Firebase I want to create different groups of users (i.e. users, admins etc) for my app. I've created some users via the console but I'm trying to find out if it's possible to assign roles to these users via the console too?
After some reading on their website firebase recommends using custom claims which can be encoded within a user's access token. This sounds perfect but the only way I can find to issue such claims is coding an app to access the admin SDK. Is there any way to achieve the same functionality but via the firebase console instead?

Multiple firebase databases with one firebase authentication

I built a web platform that allows users to signup with one user account to multiple web apps. Each app has its own separate firebase database. Is it possible to use firebase authentication and to share the same authentication between the various firebase databases? I mean like single sign on to multiple firebase database via one user base.
Please read this recent blog post on the Firebase blog. It addresses various scenarios where all your data is not in a single project.

Resources