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
sandy
April 19, 2017, 9:23pm
5
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' } } }
kaumac
July 20, 2017, 2:00pm
11
This bug is happening again, the user object does not have an id.
kaumac
July 20, 2017, 2:00pm
12
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
.
kaumac
July 21, 2017, 4:16pm
15
@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
.