I developed a multi-tenant database schema. Each subdomain connects to its respective database. Each schema has, for example, its own user table, therefore, when the user accesses the url of his own subdomain, Laravel authentication uses respective user table.
Everything is going very well, but the 'challenge' now is, I need a form where the user can select which domain he wants to connect to, but in that same form he already gives his username and password.
The point is:
- You can authenticate to a particular subdomain (example: AAA), using the credentials for that subdomain (AAA) but with the form open on another subdomain (COMPANY NAME CCC), and if redirected, with authentication done to AAA subdomain?
- Should I extend the class 'AuthenticatesUsers' and/or LoginController? I know that in the Laravel documentation there is a section 'Manually Authenticating Users'.
But if user is in the URL of CCC subdomain but user wants to be authenticated to AAA subdomain, I 'imagine' that AUTH
facade, this will use the USER
model of CCC subdomain, if this is true, so I think, I would need to be redirected first to the AAA subdomain and do an authentication after redirection, or I can authenticate first, create the authentication session from another subdomain, before redirection?