I’m using the following hook ( Pre User Registration ). However it is not working and nothing happens.
I don’t understand this because the code was already found in some of the Auth0 documentation.
module.exports = function (user, context, cb) {
var response = {};
// Add app metadata to the newly created user
response.user = {
app_metadata: { roles: ["Not Approved"]}
};
response.user = user;
cb(null, response);
};
Not sure if it’s a temporary bug as everything looks fine. Will try to look internally. Could you let me know in a few moments if it still doesn’t work?
I was inspecting you code snippet once more and it seems like you are setting user.app_metadata, then subsequently overwriting it with response.user = user. Can I ask you where did you take this code snippet from?
Has it got anything to do with API Settings? or any other component like Roles? How does user fit into either of client, scope, audience or context? By looking at the code, I am assuming the code you have mentioned is for Rules and not Hooks.
@ved.stack thank you for reporting that! Can you either provide more context around what specifically Rules and Hooks documentation lacks so I can relay to our product team or if you want you can directly submit it to the product team via our feedback site (you will be contacted by one of our product managers soon):
Also failing to get a pre-user-registration hook to successfully add app_metadata: the preview works just fine, but nothing seems to happen during an actual user login? Looking at the new user’s info via the Users console, no app_metadata exists.
Im having the same Issue with user_metada. Not even the example in the documentation is working. The hook preview works fine, but then when i test it with a “new user” the metadata section is empty
Can you let me know if you have any error message appearing or what (screenshot would be best). I need more context in order to reproduce, debug or simply inform appropriate team about it. Thanks!