is it possible like I have to entity like user and admin and i have login with admin account and want to create user account using flutter firebase
CodePudding user response:
The Firebase client-side SDKs are not designed for building administrative functionality like what you're doing. For example, they can have only one current users, and creating a new user indeed kicks out any previously signed in user. You're also likely to run into rate-limits with this approach, as it simply goes against the logic that the API/SDK was designed for.
The main options you have:
Let each user create their own account
This is the preferred approach from the Firebase API perspective, so I recommend looking into why you want someone else to create the accounts. The most common use-cases for wanting this are that you actually are trying to invite users (in which case it's better to send them a dynamic link) or to approve users (in which case you're better off creating an allow-list).
Use the Admin SDK to create the accounts, and expose this as a custom API to your client
The Firebase Admin SDKs are able to create user accounts (and with much higher quota), but can't be used in client-side code. So you'll typically want to create a custom API (for example with Cloud Run or Cloud Functions) that you can then call from your client-side code. Make sure to validate whether the user is authorized to make the call though.
Use an additional
FirebaseApp
instance in the client to create the userYou can create an additional
FirebaseApp
instance with the same configuration data, get the auth instance from that, and then use that to create a new user without kicking out the existing admin. I don't recommend doing this anymore these days, as you're still more likely to run into rate limits with it, but on an API level it is possible.
Also see: