S
S
Sasha Yashchuk2019-07-22 14:58:08
Angular
Sasha Yashchuk, 2019-07-22 14:58:08

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!
5d35a4c56f776177069522.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
orbit070, 2019-07-22
@Alex_bliznec

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 question

Ask a Question

731 491 924 answers to any question