定制 areia-lab/laravel-login-notifier 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

areia-lab/laravel-login-notifier

Composer 安装命令:

composer require areia-lab/laravel-login-notifier

包简介

Laravel package to notify users of logins from new devices or IP addresses for enhanced security.

README 文档

README

Package: areia-lab/laravel-login-notifier

A Laravel package to monitor user logins, detect new devices or IP addresses, log device and location information, and notify users and admins of suspicious or new login activity.

Features

  • Detect logins from new devices or IP addresses.
  • Send email notifications to users on new logins.
  • Send alerts to admin for every login.
  • Log device, browser, platform, IP, and geo-location.
  • Fully configurable via a config file.
  • Supports queueable notifications for production.

Requirements

This package requires the following:

  • PHP ^8.1
  • Laravel ^10.0
  • jenssegers/agent ^2.6 – device & browser detection
  • stevebauman/location ^7.0 – IP geolocation lookup

Installation

composer require areia-lab/laravel-login-notifier

Publish the configuration and migration files:

php artisan vendor:publish --tag=login-notifier-config
php artisan vendor:publish --tag=login-notifier-migrations

php artisan migrate

The migrations will create the login_histories table to store login data.

Configuration

Edit the published config file config/login-notifier.php:

return [
    'notify_user' => env('LOGIN_NOTIFIER_NOTIFY_USER', true),

    // Email address to receive admin notifications
    'notify_admin' => env('LOGIN_NOTIFIER_NOTIFY_ADMIN', true),
    'admin_email' => env('LOGIN_NOTIFIER_ADMIN_EMAIL', 'admin@example.com'),

    'secure_url' => env('LOGIN_NOTIFIER_SECURE_URL', 'forgot-password'),
];

Usage

This package works automatically on every login. You don’t need to call anything manually.

use Illuminate\Support\Facades\Auth;

Auth::attempt(['email' => 'user@example.com', 'password' => 'password']);

The following happens automatically:

  1. Login is recorded in login_histories.
  2. New device/IP detection is performed.
  3. User notification is sent if enabled.
  4. Admin notification is sent if enabled.

Access Login Histories (Facade)

The package provides a facade for querying login histories:

use AreiaLab\LoginNotifier\Facades\LoginHistory;

// Get all login histories
$all = LoginHistory::getAllHistories();

// Get recent 10 logins
$recent = LoginHistory::getRecentHistories(10);

// Get all logins for a specific user
$userLogins = LoginHistory::getUserHistories($userId);

// Get last login of a user
$lastLogin = LoginHistory::getLastLoginForUser($userId);

// Get logins from new devices for a user
$newDeviceLogins = LoginHistory::getNewDeviceLoginsForUser($userId);

Notifications

UserLoginAlert

  • Sent to users on login from a new device or IP.
  • Includes: IP, device, browser, platform, location, timestamp.
  • Includes a call-to-action button to secure the account.

AdminLoginAlert

  • Sent to admin on every login.
  • Includes user login details: IP, device, browser, location, timestamp.
  • Provides a link to review user activity in the admin dashboard.

Contributing

Contributions, issues, and feature requests are welcome!

  1. Fork the repo.
  2. Create a feature branch.
  3. Submit a Pull Request.

License

MIT License. See LICENSE for details.

areia-lab/laravel-login-notifier 适用场景与选型建议

areia-lab/laravel-login-notifier 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「security」 「login」 「laravel」 「notifier」 「2fa」 「user-authentication」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 areia-lab/laravel-login-notifier 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 areia-lab/laravel-login-notifier 我们能提供哪些服务?
定制开发 / 二次开发

基于 areia-lab/laravel-login-notifier 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-15