PHPackages                             koost89/laravel-login-links - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. koost89/laravel-login-links

AbandonedArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

koost89/laravel-login-links
===========================

Generate a login URL / link to log in as a user

v1.1.0(4y ago)123142MITPHPPHP ^7.3|^8.0

Since Jul 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/koost89/laravel-login-links)[ Packagist](https://packagist.org/packages/koost89/laravel-login-links)[ Docs](https://github.com/koost89/laravel-login-links)[ GitHub Sponsors](https://github.com/koost89)[ RSS](/packages/koost89-laravel-login-links/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (7)Dependencies (6)Versions (9)Used By (0)

[![Login Links for Laravel Logo](https://github.com/koost89/laravel-login-links/raw/main/meta/logo.png)](https://github.com/koost89/laravel-login-links/blob/main/meta/logo.png)

Generate login links for users
==============================

[](#generate-login-links-for-users)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6b87a6d57683a71a701841780d40e7201fd2536765d51c603ed8bf865d654438/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6f6f737438392f6c61726176656c2d6c6f67696e2d6c696e6b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/koost89/laravel-login-links)[![GitHub Tests Action Status](https://camo.githubusercontent.com/843490447950c69589af15de55140d7f410363bcc3fa4b9d9f55367aa21e1c71/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b6f6f737438392f6c61726176656c2d6c6f67696e2d6c696e6b732f54657374732532302d25323043757272656e742f6d61696e3f6c6162656c3d7465737473)](https://img.shields.io/github/workflow/status/koost89/laravel-login-links/Tests%20-%20Current/main?label=tests)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/851a38ebdadefaaa488a7e6d68175d53b3b4af211493f7b9e9de74e78bd7252b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b6f6f737438392f6c61726176656c2d6c6f67696e2d6c696e6b732f436865636b253230262532306669782532307374796c696e672f6d61696e3f6c6162656c3d636f64652532307374796c65)](https://img.shields.io/github/workflow/status/koost89/laravel-login-links/Check%20&%20fix%20styling/main?label=code%20style)

Login links for Laravel is a package for Laravel 6, 7 and 8 that allows users to easily log in with a (one-time) login URL.

### Quick example

[](#quick-example)

Creating a link for a user works as follows:

```
use Koost89\LoginLinks\Facades\LoginLink;

$user = User::first();
$link = LoginLink::generate($user);
```

Or you can generate a url with the authenticatable object

```
$user = User::first();
$link = $user->generateLoginLink();
```

You can also use the command

```
php artisan login-links:generate 1
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require koost89/laravel-login-links
```

You can publish the migration file with:

```
php artisan vendor:publish --provider="Koost89\LoginLinks\LoginLinkServiceProvider" --tag="login-links-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Koost89\LoginLinks\LoginLinkServiceProvider" --tag="login-links-config"
```

This is the contents of the published config file:

```
return [
    /**
     * In this file you can configure parts of login-links.
     */
    'route' => [
        /**
         * Here you can specify the path which is used to generate and authenticate the user on.
         */
        'path' => '/uli',

        /**
         * The amount (in seconds) it takes for the generated URL to expire.
         */
        'expiration' => 60 * 2,

        /**
         * The path the user gets redirected to after the login has finished.
         */
        'redirect_after_login' => '/',

        /**
         * After how many visits the token should expire
         * After the specified amount visits, the token is immediately deleted from the database.
         */
        'allowed_visits_before_expiration' => 1,

        /**
         * Extra middleware you would like to add to the route
         */
        'additional_middleware' => [
            // Middleware\AdminUser::class,
        ]
    ],

    'auth' => [
        /**
         * If you are using a different guard, you can specify it below.
         */
        'guard' => 'web',

        /**
         * Dictates if the application should remember the user.
         */
        'remember' => false,
    ]
];
```

Usage
-----

[](#usage)

### Default usage

[](#default-usage)

By default Login Links expires the tokens after 120 seconds or after a visit to the URL. These values can be changed in the config file located in `config/login-links.php`.

To get started generating URL's for your users you must run the migration mentioned above.

In your User (or other authenticatable) class add the `CanLoginWithLink` trait.

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use Koost89\LoginLinks\Traits\CanLoginWithLink;

class User extends Authenticatable
{
    use CanLoginWithLink;

    //...
}
```

After this you can generate signed URL's with the following methods.

```
use Koost89\LoginLinks\Facades\LoginLink;

$user = User::first();
$link = LoginLink::generate($user);
```

Or you can generate a url with the authenticatable object

```
$user = User::first();
$link = $user->generateLoginLink();
```

You can also use the command

```
php artisan login-links:generate 1
```

### Authenticatable classes

[](#authenticatable-classes)

Out of the box Login links uses the default `web` guard to generate links for users. If you haven't changed this in your application the default installation will work.

#### Custom guard

[](#custom-guard)

If your application uses a different guard than the default, you can specify this in the config in the `auth.guard` key.

#### Multiple guards

[](#multiple-guards)

If your application uses multiple guards with different models, you can change which guard should be used for a specific model by override the `getGuardName()` method.

For example:

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use Koost89\LoginLinks\Traits\CanLoginWithLink;

class User extends Authenticatable
{
    use CanLoginWithLink;

    public function getGuardName(): string
    {
        return 'admin';
    }

    //...
}
```

### Events

[](#events)

Events are dispatched on the following actions for you to listen to:

`Koost89\LoginLinks\Events\LoginLinkGenerated`

This event is fired when the URL is generated.

`Koost89\LoginLinks\Events\LoginLinkUsed`

This event is fired when the user is logged in after clicking on the link.

### Commands

[](#commands)

Login Links comes with a set of commands that will allow you to manage your links.

#### Generate Links

[](#generate-links)

The `login-links:generate` command takes an ID and an optional class (which by default is set to "App\\Models\\User") and returns the generated URL for you.

If you have a different authenticatable class instead of the default you can specify it with the `--class=` option. For example:

```
php artisan login-links:generate 4 --class="App\Models\Admin"
```

#### Cleanup Links

[](#cleanup-links)

The `login-links:cleanup` command is helpful to clean up time-expired tokens from your database. This package creates a record in the database for every URL that has been generated. Once they are expired, they cannot be accessed anymore. So they no longer serve any purpose and can be discarded. You can add this command in your scheduler for automatic cleanup.

```
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('login-links:cleanup')->everyFiveMinutes();
    }
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Kevin Oosterveen](https://github.com/koost89)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Recently: every ~47 days

Total

7

Last Release

1577d ago

Major Versions

v0.30 → v1.0.02021-07-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/5d291b520856d6fb927fac2e2bb783c33e876887ebdf5f2efd8f494dfead9b32?d=identicon)[koost89](/maintainers/koost89)

---

Top Contributors

[![koost89](https://avatars.githubusercontent.com/u/6790592?v=4)](https://github.com/koost89 "koost89 (90 commits)")

---

Tags

laravellaravel-loginlaravel-login-without-passwordlaravel-packageloginpasswordlesspasswordless-loginurllaravellinkuserloginauthenticatePasswordlessone-timeone-time-loginlogin linkkoost89

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koost89-laravel-login-links/health.svg)

```
[![Health](https://phpackages.com/badges/koost89-laravel-login-links/health.svg)](https://phpackages.com/packages/koost89-laravel-login-links)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[cesargb/laravel-magiclink

Create secure link for access to private data or login in Laravel without password

4571.3M](/packages/cesargb-laravel-magiclink)[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2745.0M3](/packages/auth0-login)[alajusticia/laravel-logins

Session management in Laravel apps, user notifications on new access, support for multiple separate remember tokens, IP geolocation, User-Agent parser

2011.0k](/packages/alajusticia-laravel-logins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
