I have a laravel application hosted on a.com server and this application handles all authentications for other laravel applications on other servers, Server 1 - app.com - does authentication / user management for the system and it saves in a cookie, which should be sent to servers 2,3 and 4,
server 2. mail.app.com server 3. fms.app.com server 4. dod.app.com
On servers 2,3 and 4 there is an initialization function that tries to decode cookies sent to domains from server 1., which looks something like this.
public function initialize(){ $mail = json_decode($logged_in_user_cookie)->email; $user = User::where('email', $mail)->first(); if(!$user){ $user = new User; $user->email = $mail; $user->save(); } Auth::login($user); if(Auth::check()){
Servers 2, 3, and 4 also have a user table, but without a password, therefore, if a cookie enters any of these servers, the system reads the cookie and extracts the user object from the cookie and checks if any user exists, creates the user , and then uses [Auth :: login ($ user)] to log the user into the current system, and if the user already exists .. he will automatically register the user.
now the problem we have is that on this line return redirect () -> route ('dashboard'); It redirects you to the application control panel page and dd (Auth :: user ()) - it returns null,
and we cannot understand why it works that way. since Auth :: user () should be available throughout the application, just think about it, how google works,
google.com, - one entry controls every application, including youtube drive.google.com, mail.google.com, play.google.com, news.google.com, plus.google.com, youtube.com - that's what we trying to do.