Auth0 passwordless magic links - hooks not getting called

I have a below requirement:

a) From the frontend user will enter a email. A magic link will be sent to that email ( this is done from our side and is working as expected)

b) Now when the user clicks the link and verifies the application we need a webhook which will create user record in our database.

c) For this we created a “POST registration” webhook so that we can pass the data to the RESTful api. but the api is not getting called when the user click on the mic link and verifies himself.

Below is the post registration webhook script:

module.exports = function (user, context, cb) { console.log(user); var request = require('request'); var options = { method: 'POST', url: 'URLS', headers: { 'content-type': 'application/json' }, body: user, json: true }; console.log(options); request(options, function (error, response, body) { if (error) cb(new Error(error)); console.log(body); cb(null, response); // assuming there's a response variable });

Hi @singh.ngp.pooja,

I apologize in the delayed response. I would like to reopen the topic for discussion if you have not already found a solution.

Were you getting any errors when the hook was being called? Or is the hook not being called at all? You should be able to see if this is happening in the logs. This could also be accomplished in a rule if you are not able to get the hook to work correctly.

I hope this helps,
Dan

Regarding

console.log(user);

This won’t be logged anywhere in the Webtask Realtime Debugger, because it (post-user registration hook, as opposed to a pre-user registration hook) happens asynchronously. Just want to be sure that you don’t assume nothing is called because you don’t see anything in the webtask log on Auth0 side.

And to be sure:

From the frontend user will enter a email.

This email/user does not yet exist in Auth0, right?

Update:

I just tested it myself and found that for passwordless connections, the pre-user registration hook is being called, but not the post-user registration hook.
For database connections with username/password, both are called. That seems weird, I will clarify if this is intentional.

And as @dan.woda suggested, you could use a Rule instead, and via context.stats.login_count==1 in the rule you can check whether it’s a new signup or an existing user.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.