Hello! I setup netlify CLI and started a dev environment for developing. I want to test identity function events. On login, I want to add a metadata to a user. But, after walking in circles through the docs and github, I couldn’t test it out the function properly.
Both the identity and user that are supposed to be set are undefined. Am I doing something wrong? I thought that netlify would mock some data for these type of events. How can I test identity? I wish to set the metadata and then check if the data is there, so I can move on with testing other logic around it. So I need some test-user account.
context contains Identity related data only when called with the Authorization header.
identity-login function contains the Identity-related data in the event body.
Looks like you’re merging both of those concepts. Also, I don’t think you can successfully invoke event -driven functions by the functions:invoke command. You probably need to trigger the event for that function from the front end.
Hmm… But when I login in the localhost frontend, the identity-login.ts function doesn’t trigger. Nothing is logged out in the terminal, neither I get any feedback for the response.
The problem is probably that event-driven functions expect the data in event.body , but normal Identity-based functions (that are called with the Authorization header), have this data in context.clientContext . So, you’ll have to change the code to this: