Post registration hook - user id

Hi,

I need to access user.id in post registration hook, but it seems its undefined

module.exports = function(user, context, cb) {
  // Perform any asynchronous actions, e.g. send notification to Slack.
  request({
    method: 'POST',
    url: 'http://dumy.com/api',
    headers: {
      'Content-Type': 'application/json',
    },
    body: `{  "email": "${user.email}", "fkAuth": "${user.id}" }`
  }, function(error, response, body) {
    console.log(user)
    console.log(context)
    cb(error, response)
  });
};

In user there is no attribute id, is there any other option how to obtain it ?

This was found to be a bug which has now been resolved. You can access the id through user.id.

user.user_id is also undefined. This is user object, no ID inside

 { tenant: 'my-tenant',
  username: 'user1',
  email: 'user1@foo.com',
  emailVerified: true,
  phoneNumber: '1-000-000-0000',
  phoneNumberVerified: true,
  user_metadata: { hobby: 'surfing' },
  app_metadata: { plan: 'full' }
}

Any update on this bug? user_id is not accessible in the post-registration hook

How are you able to do a POST request? I’m getting a 500 error when I try to do a POST. =(

Any update on this bug? user_id is not accessible in the post-registration hook

user.user_id is also undefined. This is user object, no ID inside

 { tenant: 'my-tenant',
  username: 'user1',
  email: 'user1@foo.com',
  emailVerified: true,
  phoneNumber: '1-000-000-0000',
  phoneNumberVerified: true,
  user_metadata: { hobby: 'surfing' },
  app_metadata: { plan: 'full' }
}

Thanks for pointing this out. We have resolved a bug that was causing this - you should now be able to use user.id.

Hey! I still don’t get the id attribute in the user object. When I log it in the hook dev console, it’s undefined. Any update?

To the Auth0 team: I confirm that it’s impossible get the id attribute in the user object. Her’s what I get when I log it in the hooks dev console:`

{ user: { tenant: 'my-tenant', username: 'user1', email: 'user1@foo.com', emailverified: true, phonenumber: '1-000-000-0000', phonenumberverified: true, user_metadata: { hobby: 'surfing' }, app_metadata: { plan: 'full' } } } 

This bug is happening again, the user object does not have an id.

This bug is happening again, the user object does not have an id.

@kangarup @kaumac I am looking into this on my end.

@kangarup @kaumac can you confirm whether this issue is still happening for you? I have tested on my tenant and see user.id.

@prashant it is actually working, sorry for my mistake. I just didn’t have an id on the request body on the webtask editor. But when the hook is actually called from a real event, the id is there.

@christiankindhealth thanks for pointing this out. We found a bug which has been resolved - you should now have access to user.id.