How can I know that a user has logged in or registered after authenticated

I’m using Lock and I’m wondering how can I know that a user has been already registered or just a new user?

You can use a rule to add an attribute to the user_metdata of the user profile to indicate whether the user had logged in before.

So, for example, if the attribute newUser doesn’t exist, create it and set it to TRUE (meaning that the user is a new) . If the attribute does exist, set it to FALSE (meaning that the user already registered and this is a login).

Use this rule example, Add persistent attributes to know how to add an attribute in the metadata:
https://github.com/auth0/rules/blob/master/rules/add-persistent-attributes.md