Support the ongoing development of Laravel.io →
Authentication Session Database
Last updated 1 year ago.
0
Solution

Dump&Die the $user variable. Its a array of POPObjects. You can not pass it into Auth::login(User $user). So, you need to extract the id of the user and pass it to Auth::loginUsingId(int $id)

Here is a Eloquent example :

$user = User::whereEmail($result['email'])->first(['id']);

if (empty($user)) {
    $user = new User;
    ...
    $user->save();
} 

Auth::login($user);

Also note that you require $user variable but you are creating user as $data variable which is also why you getting errors.

Last updated 1 year ago.
0

Thank you :) It's working now

Last updated 1 year ago.
0

@mcraz Just noted that it shows this error: Argument 1 passed to Illuminate\Auth\Guard::login() must implement interface Illuminate\Auth\UserInterface, null given when user is logged in for the first time. And then when page is refreshed user is logged in.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

laureta laureta Joined 17 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.