Hello,
It seems you’ve encountered a common issue when integrating Socialite with Laravel for social authentication, where users authenticated via social providers do not have a password. The error arises because Laravel’s session authentication middleware expects a password hash to verify the session.
Your proposed fix is on the right track. By adding a condition to check if the user has a password before comparing the session hash, you can prevent users without a password from being logged out. Here’s the adjusted code snippet for clarity:
if ($request->user() && $request->user()->password) { if (! hash_equals($request->session()->get('password_hash_'.$this->auth->getDefaultDriver()), $request->user()->getAuthPassword())) { $this->logout($request); } } This modification ensures that the password hash check is only performed if the user has a password set, which is not the case for users authenticated through social providers.
I hope the information may helps you.