Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GimmeMylanta's avatar

Detecting first time login of API only using Sanctum

Im building a API only system with Laravel Sanctum. When a user logs in for the first time, I want the response to reflect this.

Has anyone implemented this? What would be the best way of doing it?

0 likes
3 replies
bugsysha's avatar

The first time when the user is logged in is the time when he registered. So go to EventServiceProvider and add an additional listener to the Registered event.

bugsysha's avatar

I know you don't login them during registration, but I assume you return all the details required for a user to make a request as an authenticated user after the registration? Since API is stateless that still can be considered as a first login point.

Please or to participate in this conversation.