nikfedorov/auto-login

Auto-login middleware for Laravel — logs in the first database user in allowed environments during development.

Maintainers

Package info

github.com/nikfedorov/auto-login

pkg:composer/nikfedorov/auto-login

Transparency log

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-11 18:36 UTC

This package is auto-updated.

Last update: 2026-07-12 07:28:19 UTC


README

Middleware that automatically logs in the first database user in allowed environments — skip the login screen during development.

If no user exists yet, the request passes through unauthenticated. Run your seeders first.

Requirements

  • PHP 8.2+
  • Laravel 11 / 12 / 13

Installation

composer require nikfedorov/auto-login

Then register the middleware:

php artisan auto-login:install

This adds the middleware to bootstrap/app.php:

->withMiddleware(function (Middleware $middleware): void {
    $middleware->append(AutoLoginLocal::class);
})

You can also register it manually instead of running the command.

Optionally publish the config:

php artisan vendor:publish --tag=auto-login-config

Configuration

Env variable Default Description
AUTOLOGIN_ENABLED true Enable or disable auto-login globally
AUTOLOGIN_ENVIRONMENTS local Comma-separated list of allowed environments

How it works

On each request:

  1. Skips if the user is already authenticated.
  2. Skips if auto-login.enabled is false.
  3. Skips if the current APP_ENV is not in auto-login.environments.
  4. Resolves the user model from auth.providers.users.model, grabs the first record, and logs them in.

In any environment not listed in AUTOLOGIN_ENVIRONMENTS (e.g. production, staging) the middleware is a no-op.

Testing

composer test