Download the PHP package codebyray/laravel-auth-log without Composer
On this page you can find all versions of the php package codebyray/laravel-auth-log. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codebyray/laravel-auth-log
More information about codebyray/laravel-auth-log
Files in codebyray/laravel-auth-log
Package laravel-auth-log
Short Description Log user authentication details and send new device notifications.
License MIT
Homepage https://github.com/codebyray/laravel-auth-log
Informations about the package laravel-auth-log
Laravel Auth Log is a package which 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.
Documentation, Installation, and Usage Instructions
Installation
Installing the package via composer:
If you want to use the location features you will need to install torann/geoip
If you choose to install torann/geop
you should publish the config file:
Setup / Configuration
Publish and run the migrations:
Publish views and email files:
Publish the config file:
Config file contents:
Setup The User Model
In order to log the events above you need to add the AuthenticationLoggable
and Notifiable
traits to your model. The Notifiable
is normally setup when you generate a model using the artisan make:model
command, if it does not be sure to add it.
This package will listen to Laravel's Login, Logout, Failed and OtherDeviceLogout events.
Usage
Getting The Logs
Get all the authentication logs for a user:
Get the users last login information:
Get a users previous successful login time or IP address:
In the above examples you can use auth()->user()
to get the logs for the currently logged in user.
Notifications
Notifications are sent out via email by default. You can sent them to be sent by 'mail', 'nexmo' and 'slack' by setting them in your 'Authenticatable' model.
To setup the channels you want notifications sent, you nee to define the 'notifyAuthenticationLogVia' method in your Authenticatable
model.
In order to use 'Slack' and/or 'Nexmo', you need to install the drivers for each and follow their documentation for setting up your 'Authenticatable' models.
New Device Notifications
Enabled by default, they use the \Codebyray\LaravelAuthLog\Notifications\NewDevice
class which can be overridden in the config file.
Failed Login Notifications
Enabled by default, they use the \Codebyray\LaravelAuthLog\Notifications\FailedLogin
class which can be overridden in the config file.
Location
If the torann/geoip package
is installed, you will need to enable locations via the config file. This is disabbled by default.
You can turn this on within the configuration for each template.
Note: By default when working locally, no location will be recorded because it will send back the default address from the geoip config file. You can override this behavior in the email templates.
Purging Old Logs
You can purge the logs using the following artisian command:
Any records older than the specified number of days in the config/auth-log.php
file via the purge
setting will be deleted. Default number of days is 365.
You can schedule the command to run automatically every month, or however often you'd like using the following command:
Version Compatibility
Laravel | Auth Log |
---|---|
9.x | 1.x |
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Ray "RJ"
- Original Code - rappasoft/laravel-authentication-log
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-auth-log with dependencies
illuminate/contracts Version ^9.0
spatie/laravel-package-tools Version ^1.4.3