The 'authenticated'
event is emitted after a successful authentication.
lock.on('authenticated', function(authResult) { });
But is there any way to detect when a new user signs up to your application or do I have to store the user in my database and check it each time a user authenticates?
The Auth0 Lock does not trigger a specific event for user signup.
You can however detect this on a custom rule and enrich the user profile with this metadata. There's a signup sample rule that illustrates this possibility
This uses
app_metadata
to store information associated to the user so that you can keep track for which users you already executed their additional first-time signup logic.Have in mind that rules will execute on the server-side of the authentication pipeline, so if the logic you want to implement requires user interaction you could achieve something similar by doing these set of steps:
app_metadata
to set a signup flag (you can do this on your server-side application logic through Auth0 Management API)