I am building a mobile app for a company with a few employees. Each employee has a unique employee ID that can be used as their account identifier. I would like to know how I could create these users in firebase using their employee ID as the username / id as a preset password.
Something like:
[
{
"emp_id": 123, //Login username
"passwordHash": "LKWrHLwsFlbY4AylsPQ", //Password
"name": "John Doe"
},
{
"emp_id": 456,
"passwordHash": "ZQXyTXf8EXlAWX1f",
"name": "Jane Doe"
}
]
The employees will have an ID to login that will never change and a password that they can change at will. There is no way to sign up / register. Any new employee will be manually added by an admin.
How to I set up this type of authentication method in firebase? They seem to be forcing their own auth systems (which are neat and all, but not what I need)
Enable anonymous auth: In the Firebase console, open the Auth section. On the Sign-in Methods page, enable the Anonymous sign-in method. Optional: If you've upgraded your project to Firebase Authentication with Identity Platform, you can enable automatic clean-up.
Adding members to your Firebase project allows you to collaborate across your team. You can assign each member a role based on the level of access the member needs for your project. Project members are not limited to just individual users: domains, groups, and service accounts can all be members of a Firebase project.
No Firebase Authentication…To use the Firebase Storage we need to authenticate a user via Firebase authentication. The default security rules require users to be authenticated. Firebase Storage is basically a powerful and simple object storage, in which you can store your files easily.
There is no built-in support in Firebase for signing in with just a username and a password. The closest you can get with the built-in providers is to create accounts with fake email addresses, such as [email protected]
. But it's less then ideal, since it is somewhat assumed that you can send password reset emails for email+password accounts.
Since none of the built-in identify providers do what you need, you need to create a custom authentication provider for this. This requires that you can run code to mint tokens in a trusted environment, which can be for example your development machine, a server you control, or Cloud Functions for Firebase.
For an example of a custom provider implementing username+password authentication on Cloud Functions, have a look at this page in the function-samples
repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With