After learning sending email verification is possible in latest firebase, although the docs are missing that, I wanted to test it for myself.
Using the snippet below:
Auth.$onAuthStateChanged(function(firebaseUser) {
if (firebaseUser) {
console.log(firebaseUser);
if (firebaseUser.emailVerified) {
// console.log(firebaseUser.emailVerified);
toastr.success('Email verified');
} else {
toastr.info('Do verify email');
}
}
})
The console.log(firebaseUser.emailVerified)
returns false, always, although a send verification was initiated, email received, and clicked on.
Right after login with email, I check to see if user is verified, if not, email should be sent:
Auth.$signInWithEmailAndPassword(email, password)
.then(function(firebaseUser) {
if (!firebaseUser.emailVerified) {
firebaseUser.sendEmailVerification();
console.log('Email verification sent');
}
$state.go('home');
})
Under my https://console.firebase.google.com/project/my-app-name/authentication/emails
, everything is by default, with a verify link as:
Follow this link to verify your email address.
https://my-app-name.firebaseapp.com/__/auth/handler?mode=<action>&oobCode=<code>
The email I use to sign up receives the verify email message, yet, clicking the link does nothing to change the user.emailVerified
to true.
Are the steps outline here all there is, or there's yet another step not found in the docs?
Firebase offers a handy tool for that called email verification link, and it's a link you send to your users' emails, they can click it, and it will verify their emails inside of Firebase Authentication. Then you can decide to only give access to verified users, or run a cleaning tool to remove non-verified users after set period of time.
How to send email verification link with firebase using ReactJS? 1 Step 1: Create a React myapp using the following command.#N#npx create-react-app myapp 2 Step 2: After creating your project folder i.e. myapp, move to it using the following command.#N#cd myapp More ...
To set up a verification link you first need to decide on when you want to ask for the verification, in this example, you’d want to send the email as soon as the user signs up, that way you can give access only after they verify their emails.
Before you can authenticate users with email link sign-in, you will need to enable email link sign-in for your Firebase project. To generate a sign-in link, provide the user’s email and an ActionCodeSettings object.
As mentioned by Tope in a comment, you need to do a firebaseUser.reload()
in order for the change to the firebaseUser's authentication status to be updated.
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