# How can I detect first login after email verification

**URL:** <https://community.auth0.com/t/how-can-i-detect-first-login-after-email-verification/100442>\
**Category:** Get Help\
**Tags:** identifier-first, login-experience\
**Created:** [February 14, 2023, 8:08am UTC](https://community.auth0.com/t/how-can-i-detect-first-login-after-email-verification/100442 "2023-02-14T08:08:17Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![wayne.lim](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wayne.lim/32/44587_2.png) [@wayne.lim](https://community.auth0.com/u/wayne.lim)\
**Post date:** [February 16, 2023, 4:04am UTC](https://community.auth0.com/t/how-can-i-detect-first-login-after-email-verification/100442/4 "2023-02-16T04:04:44Z")

</div>

Hello @ramazan ,

Thanks for clarifying.  
You can detect first login by creating a Post login action and checking for [event.stats.login\_counts](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/event-object).

For example, you can create a rule to detect first login (counts ===1) and assign app-token there.

```auto
exports.onExecutePostLogin = async (event, api) => {
  if(event.stats.logins_count === 1){
    //assign app-token here
  }else{
    //not first login
  }
};

```

This is quite similar to a use case in the Community and attaching for your reference.

> [@How to distinguish first login after sign up](https://community.auth0.com/t/how-to-distinguish-first-login-after-sign-up/94885/4):
>
> Post-Login Actions do occur for silent authentication requests. A reliable solution would be to see if stripe\_customer\_id already exists in the user app\_metadata object, and skip the action for the user if it does. However, if you need to rely on first logins only in the Post-Login Action flow instead, something like below might help // check if user has more than one login, or if this is a refresh token rotation, or a silent auth request const not\_first\_login = event.stats.logins\_count \> 1 |…

Let me know how it goes, thanks!

---

_[View the full topic](https://community.auth0.com/t/how-can-i-detect-first-login-after-email-verification/100442)._
