C
C
Cathari2020-09-24 11:18:21
Laravel
Cathari, 2020-09-24 11:18:21

What event to use or where is it necessary to get ip usera upon login?

I use the standard event Login from

'Illuminate\Auth\Events\Login' => [
            'App\Listeners\LogSuccessfulLogin',
        ],


in LogSuccessfulLogin I send a letter to user'y in which I want to show his ip
public function handle(Login $event)
    {
            Mail::to($event->user)->send(new UserLoginEmail($event->user));
    }


I get ip in LoginController, in which I rewrite authenticated

function authenticated(Request $request, $user)
    {
        $user->update([
            'last_login_ip' => $request->getClientIp()
        ]);
    }


But the trouble is that I get it ip after sending the letter. Maybe I'm using the wrong event (although I tried others) or I'm processing its receipt in the wrong place?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question