I have two clients set up (Client1, Client2) with their own database connections (DB1, DB2). Client1 already has users, and I would like these users to be able to log in to Client2, but do not want users from Client2 to be able to log in to Client1.
I currently have Client1 set up with only the DB1 connection, and Client2 set up with DB1 and DB2 connections. However, when a user signs up for Client2, their user is being created in DB1 instead of DB2.
How can I choose which connection new users are created in?
I am using the Auth0 Wordpress plugin which is currently using Lock 10. I would prefer to have new users stay in their clients respective DB, not signed up in both databases. Would a rule work for this? I looked at the defaultDatabaseConnection
setting, but this still restricts to a single database. It looks like the WordPress plugin will allow me to user Lock 9. Would I be able to get the functionality I am looking for with Lock 9?
Another option I have thought about is consolidating all users into one connection and using metadata to differentiate between them. However, I am not sure how this would work through the WordPress plugin.
The /dbconnections/signup
endpoint requires a connection
parameter that will indicate in which connection the user will be registered in. With this in mind and based on the information you provided you’re likely using a sign-up mechanism that is choosing this connection automatically for you; my assumption is that you may be using Lock for the sign-up operation.
The Lock library is a great way to have an authentication/registration interface setup in no time, but it does come with its own assumptions. For example, the UI has a single set of input for email and password and as such by default it does not fully support more than one database connection because it would not know how to distinguish between them.
If the above assumption is correct you should update your question with additional details in order to see what are the reliable alternative for that use case. In particular, you should state the version of Lock being used, if it’s being used as part of the hosted login page or embedded in the client application, how the Lock instance is being configured, and if you need to support sign-up to both databases at the same time for the same client application.
On the other, if you’re not using Lock then it’s a matter of being explicit in the call to the sing-up API and specify the appropriate connection name.
Thanks @jmangelo. I updated my question with info on my setup.