i am using multi mysql DBs mysql, mysql2, mysql3 are the connection names. at login it check the user and pass in all DB and login - dd(Auth::user()) shows proper user data as per respective DB in loginController just after auth()->attempt() lets say user from mysql2 named user2 - showing here
but when user if redirected to dashboard dd(Auth::user()) started to show data from 1st default connection DB lets say it user1 - but we login the user2
Note: the Auth::user() data is not proper - rest of the data is coming properly - the issue is with Auth::user() only
i tried to print dd(Auth::user()) in login controller showing proper data in HomeController showing data from 1st DB instead of login one.
- i tried to change the default connection
- i tried to empty the default connection
- i tried all available methods on stackoverflow + laracasts
- Further i tried multiple guards and provider with proper db connection inside config.auth.defaults.guard
Note: DB user is same for all databases - phpmyadmin user
It's hard to tell specifically without your code as this could happen due to multiple reasons. Ensure that you've properly set up multiple guards and provides in the following way:
Also ensure you're callling the proper guard when attempting to authenticate a user:
Also after authenticating set the appropriate database connection for the auth user session using the
setDefaultConnectionmethod from theDBfacade. Do the same also when registering an user.And finally try: