create organization in databaseHooks.user.create.after
I want to ensure that for all created users without an invite link, an organization (using the organization plugin) is created for them automatically on sign up.
Ideally also set this freshly created organization as their active organization on the client.
Is there a way to create an organization for a user that has just been created? I was thinking of using this database hook:
Any workarounds or solutions for this? Thank you!
5 Replies
That sounds doable! Maybe try taking the path from the context as it'll be different from users that accept an invite.
As for the hook, just create a function in a lib file?
Hoping I haven't missed the mark here haha
Solution
To follow up ^^, here is how you can create org from server auth api:

Thank you for the replies! I'm not sure if I'm missing something, but since the hook si defined inside the
auth
instantiation options, I cannot call auth.api.createOrganization
from within, can I?
No, this is totally valid
thank you!