Alter user password at creation using Database action scripts


I’m currently working on an app where users are created in-app by a logged-in admin user. Our workflow for creating a new user would look like:

  1. The admin-user is logged in on the app
  2. The admin-user goes to a user creation form
  3. The admin enters the name and email of the new user. The password will be randomly generated.
  4. The new user is created in the database
  5. An email is send to the new user, so he can change his password.

For reasons, we would like to generate a random password server-side+ during the API call to Auth0. So our idea was the alter the password field of User in the Database Action Scripts (because it is a required field for the API call), but it “doesn’t” work. By that, I mean that an unknown error is returned and the User is created in our MongoDB, but doesn’t appear in the Auth0 management dashboard.

I’ve tried different ways, but all do the same (like explained previously):
- user.password = “exemple123”
- let newUser = { …user, password : “exemple123” }, then replace all instance of “user” by “newUser”
- replace the hash param by “exemple123”
- hooks on the same principles

So, my question is: is it possible to alter (create server-side) the password duing the API call or do I need to create it before-hand?

Thanks in advance!