mercredi 30 septembre 2015

How to have a multi tenant database in laravel where every tenant has multiple users?

So I am trying to understand how a multi tenant database approach works but I am confused in some places. I am trying to use it in Laravel and MySQL

I understand that I can have a databases for each tenant in my application so when a user logs in, I can just check which tenant it is and change the DB connection to use their database. I am guessing this is how it works.

But now here is where I start to get confused. The tenant that logs into the application will be able to create users and assign them roles which means that there is super admin which creates all the tenants but then there is also a super admin for a particular tenant which will creates users for the instance of the tenant itself.

So now how will I authenticate users in such a situation. For example, I can authenticate a tenant and then change the DB connection to the appropriate database but then I will have to log in the user of that particular tenant and how will I keep two enitities logged in at the same time in the session?

I am guessing a multi auth package (like Multi Auth) might help in doing that but since I am new to this I am mostly blurry.

I am hopping someone has already encountered this problem and might be able to help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire