hello everyone, my current application is very simple, it has registration, login, forgot password and forgot email. I am using firebase authentification block “send reset password email” when my user wants to change their password, as shown below
so, it just sends an email typed by the person by firebase itself, where their password changes in authentification. The problem is that it doesn’t change automatically, either, in the realtime database, which has a tag called “senha” (password).
When the person chooses “update e-mail”, they have to type the password that is in realtime, not in auth. that is, who confirms whether the password is the same in the database, is realtime.
Thus, my question: is there a way to change a password with an email sent by auth, which also changes the password in realtime? or a way to compare the password entered by the user with the password from auth, not from realtime?
I’ve already researched about it in the community and on YouTube, but either I can’t find it, or it’s outdated content.
I solved it! Guys, what I did was the following, as shown in the photo below:
my global variable is the id user in auth. i do the normal login process as shown below
What I did, as shown in the first image, is that every time the user changes the email or changes the password, if they are authenticated, the moment he logs in again the “password” and “email” tags will be deleted from the database and new email and password tags will be created with the new data in place of the old ones. Thus, both auth and realtime are updated with the same data and without interrupting the user.
It may not be the best method, but it works. As this project is urgent, it has been great for me, and I intend to optimize it in the future.
(also, i do the same when i update email. i ask for the password, then if it’s authentificated, the database delete the old email tag and replaces with the new one)