Admin to add users to their organisation

Hi all. I'm building out a Saas project in next.js where I will have clients set up as organisations and each client will have multiple users. I've implemented admin and organisation plugins, have created some organisations and created some users which is all good. The lead user (as an admin) can create other users but how do these new users get assigned in to the organisation? I have basic RBAC established so that only an organisations users can see data/ other users in that organisation.
3 Replies
Ping
Ping4w ago
In the flow where admins can create users - could you make a separate endpoint to then assign these users to their represented orgs? (Of course don't forget to add authorization in this endpoint to check if the user requesting for this is an admin)
mrbusy
mrbusyOP4w ago
I have a separate function that uses auth.api.addMember() but how does the Admin user obtain the newly created users ID? Or would the addMember function get called in the onSuccess() statement of admin.createUser()
Ping
Ping4w ago
Yeah, in the success statement of createUser, you should get the userid, then you can call your addMember function.

Did you find this page helpful?