4 years ago

Using Auth on a different connection or database.

Posted 4 years ago by gauravchandiramani

I'm very new to Laravel and am currently building a multi-tenant app. Basically when anyone signs up for an account a new database along with tables, indexes and data gets created. I've managed to create these tables and also managed to switch dynamically between the default database and the account database to retrieve and insert data. I use Config::set() to basically switch between databases on the fly.

I'm currently stuck with user authentication. User signup works fine and all user credentials are stored in their respective account databases. So let's say account ABC has 3 users. Their email and password will be in "databaseabc". When a user wants to login, Auth should basically switch to the accountdb and check on the users table there (the default database has no users table). Passing parameters (database name, database username, database password) to AuthController is not a problem. I just need to know how to switch to it using the account database instead of the default one. I tried using Config::set() in AuthController but that didn't help.

Please let me know if anyone has any ideas about this.

Thank you.

Please sign in or create an account to participate in this conversation.