I am working on a web app with an existing user base. Email verification was not initially implemented in the sign in flow.
I have successfully added code for sending verification email for all new sign ups but I also wanted to make a small page (or modal) where current users would be shown a button that would send the verification link to their inbox
The current sign up flow where I created the user with createUserWithEmailAndPassword
I was able to get access to the user.user.sendEmailVerification
method to do so, but cannot find any way to access this method to implement the feature for existing users.
Is there a way to access the sendEmailVerification
method after the user has been created?
I am assuming that it would be available within the
onAuthStateChange
trigger but implementing that would lead to a bad UX (as I do not want to prompt the users everytime they login)
Edit:
I know the documentation states that we can use the firebase.auth().currentUser
to get the current user but that, for some reason did not work.
Also, I found references online suggesting to no longer use that method and they mentioned to use the onAuthStateChange
method instead, which is why I was looking into that approach