Set role/metadata on initial call to /invite
See original GitHub issueOur application programmatically invites users (on Netlify Functions) following the example in the documentation.
However, if we send a payload that includes app_metadata
while inviting a user (e.g. {email: test@example.com, app_metadata: {roles: ['admin']}}
), the user test@example.com
gets successfully created but any app_metadata
is ignored.
Is it possible to set the role/app_metadata
directly in the initial call to create the user? I realize it’s possible to update the user in a separate followup API call but I’d like to limit requests if possible.
Is this supported? Not sure if I’m using the API correctly and/or this might be a bug since the API response example in the documentation seems to suggest it might be possible to set roles directly in the initial call.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
Hi @DavidChouinard , the user has to exist before you can add a role. If I were you I’d create a webhook that fires on signup or validation that assigns the role. It can be similar to what @shortdiv is doing in her example: https://github.com/shortdiv/identity-with-role-based-access/blob/master/src/lambda/handle-signup.js
Hey @DavidChouinard, generally, email is saved under
user_metadata
, so you could do something like this:You can see an example of this in a function here, which shows how to add extra metadata to a user during the sign up flow.