samedi 3 mars 2018

Laravel: How to Auth for Multi-Domain

I have one Laravel app for three websites, that are listed in my .env file

A_DOMAIN=example-A.com
B_DOMAIN=example-B.com
C_DOMAIN=example-C.com

My admin area is at example-A.com/admin. I want now that the admin can login with a user to one of the other domains.

This is what I tried so far:

public function login(User $user, $orga)
{
   \Auth::->login($user);

   return redirect(env($orga . '_DOMAIN'));
}

The problem is that since the admin area is at example-A.com/admin the call \Auth::->login($user); will login the user at example-A.com. This means that login($user, 'B') does login the user at example-A.com and then redirect to example-B.com where the user is not logged in.

My question: How can I login the user for any of the other domains of my app? Or is it possible to login a user at all 3 domains at the same time?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire