Hi David. Not sure what the error that you are getting is, but you should be able to access a user’s user_metadata
from a pre-registration hook. You can try this simpler version (to simplify the code and remove the possibility of the external request failing):
module.exports = function (user, context, cb) {
// this will output the full user object, and you should
// be able to see its `user_metadata` object populated
console.log(user);
var response = {};
response.user = user;
cb(null, response);
};
You can watch the console.log(user)
output by running the Real-time Webtask Logs.
If you are still not seeing the data, you might want to try a cURL
post directly to take Lock also out of the picture, with something like this:
curl -X POST \
https://YOUR_AUTH0_DOMAIN/dbconnections/signup \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"client_id":"A_VALID_CLIENT_ID",
"email" : "test789@test.com",
"password":"test",
"connection":"Username-Password-Authentication",
"user_metadata":{"name": "john","color": "red"}
}'
One final note, that might be obvious but could be easy to miss: remember to select the hook that you’ll want to use as the “active” one in the dropdown list (you can create multiple hooks but choose only one to run).