Laravel Authentication Logs

Packages

October 8th, 2021

laravel-authentication-logs-featured.png

Laravel Authentication Logs is a package by Anthony Rappa that tracks user authentication details:

Laravel Authentication Log is a package that tracks your user's authentication information such as login/logout time, IP, Browser, Location, etc., as well as sends out notifications via mail, slack, or SMS for new devices and failed logins.

If you've ever received new login notifications for services such as Netflix, this is an excellent way to keep users informed when new logins occur. At the time of writing, this package has notifications for new device logins and failed login attempts.

Using the AuthenticationLoggable trait provided by the package, you'll get the following API to access authentication logs:

1$user = User::find(1);
2 
3// Get all authentication logs for a user
4$user->authentications;
5 
6// Last login details
7$user->lastLoginAt();
8$user->lastSuccessfulLoginAt();
9$user->lastLoginIp();
10$user->lastSuccessfulLoginIp();
11 
12// Previous login (excluding current login)
13$user->previousLoginAt();
14$user->previousLoginIp();

The readme has further details on displaying logs, purging old logs, and more. You can learn more about this package, get full installation instructions, and view the source code on GitHub.


This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.