Not sure if I am doing something wrong but using this api https://www.firebase.com/docs/security/simple-login-email-password.html I can successfully create a user - according to the return message, but I can not see that user anywhere in the Forge console. How do you know what users are registered?
Should I be taking the return user ID and creating my own user object in Firebase or is this duplication unnecessary. I do need to add some additional user properties so perhapes I will need to do this anyway.
To get all the users from auth in Firebase, you can use the Admin SDK for Firebase. It gives you elevated privileges to perform operations in the system that a normal user can not. The Admin SDK comes with a lot of functionality built-in.
There's no built-in method to do get the total user count. You can keep an index of userIds and pull them down and count them. However, that would require downloading all of the data to get a count. Then when downloading the data you can call snapshot.
To detect if a user is already logged in Firebase with JavaScript, we can call the onAuthStateChanged method. firebase. auth(). onAuthStateChanged((user) => { if (user) { // ... } else { // ... } });
When using email / password authentication in Firebase Authentication (previously known as Firebase SimpleLogin), your user's email and password combination is securely stored separately from the data actually stored in your Firebase.
This barrier between the data in your Firebase and your users' email / password hash combinations is by design: we want to make it easier for you to (1) develop your application, (2) prevent any accidental user credential leaks, and (3) still give you total flexibility with how to store your user data in Firebase.
That means that we only store the email address / password hash combination and nothing else, so it is up to you to decide how to store actual user data in your Firebase. As you suggested, you should be taking the user id and storing that data in your Firebase in a location such as /users/$id, and using the Firebase Security Rules Language to determine read / write access to that data. Your user's unique id
and email
are already in the auth
variable you'll use when writing rules.
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