Answer the question
In order to leave comments, you need to log in
How to correctly set up authentication in firebase using email and password?
Good day everyone! Can't figure out how to properly set up authentication in firebase. My application already knows how to add a user's document to the collection using the .add() method, I can also register a user using the .createUserWithEmailAndPassword() method, and a field with the user is created in the "authentication" tab.
But now I can’t understand how it all should work ...
Previously, I didn’t have anything to do with firebase and got used to the fact that with the classic registration scheme, I just checked for the presence of a user in the database and, if not, created a new user document and called the method, which immediately logged him in.
How to be here, I can’t quite understand ... I need the user’s document to be created in the database and registered, i.e. do I need to call both the .createUserWithEmailAndPassword() method and the .add() method?
And tell me, what is this storage where the user's document is saved when calling .createUserWithEmailAndPassword()?
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
The question is too watery to give a normal answer.
Method "createUserWithEmailAndPassword()" - for registration.
By analogy, there is a method for login - "signInWithEmailAndPassword()".
You can read about them here .
The add method has nothing to do with authorization and is used to add data to the database.
If your rights to the database state that only authorized users can add data, then first register / log in using the methods above, then call add to add data. If any user can add data, then authorization is not needed - just call the add method directly
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question