Verification emails is not being sent on first login for existing users

Hey community,

in the description of how email verification works, there is a text

This email will be sent whenever a user signs up or logs in for the first time.

It works fine for new users, they receive verification emails. But we also have a feature implemented when existing users go through the login flow and they are not in auth0 yet. For those existing users, we create an account and their logins_count is 1 but the verification email is not being sent (it works for them when you trigger an API call to send the verification email again). Is there any setting that is potentially disabled or is that expected behavior?

Appreciate any help on this!

Hi @serhii2! Welcome to the Auth0 Community! Apologies for the delay in response. Let me track down an answer to this for you.

1 Like

Thanks! waiting for any information about it! Appreciate it

Hey @serhii2, after doing a bit of research it seems like what you’re looking for is a post login action to force email verification.

It would look something like this :

exports.onExecutePostLogin = async (event, api) => {
  if (!event.user.email_verified) {
    api.access.deny("Please verify your email before logging in.");

Here’s a link to the docs that could also help: Auth0 Login Flow

you are right, that’s what we are doing. In the “Email Templates” section for Verification email, it says that auth0 automatically sends this email on the first signup/login. (see attached pic)

On the Sign up it works well but not in the first login. By the first login, I mean the first login that auth0 can record, for example for existing users who are already in our system but not in auth0 yet. So technically for them it would be first login, right? However, those users do not get that verification email on the first login.

So my question is: do we need to call API for existing users on first login(to trigger sending of verification email) or auth0 should handle it? If we need to do it ourselves then what does “logs in for the first time” mean?