PHPackages                             tecnomanu/unilogin-laravel-lumen - 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. tecnomanu/unilogin-laravel-lumen

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

tecnomanu/unilogin-laravel-lumen
================================

A universal authentication package through magic link

v0.1.0(2y ago)02MITPHPPHP ^7.3|^8.0

Since Jun 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tecnomanu/unilogin-laravel-lumen)[ Packagist](https://packagist.org/packages/tecnomanu/unilogin-laravel-lumen)[ Docs](https://github.com/tecnomanu/unilogin-laravel-lumen)[ RSS](/packages/tecnomanu-unilogin-laravel-lumen/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (9)Versions (3)Used By (0)

UniLogin
========

[](#unilogin)

UniLogin is a Laravel/Lumen package that allows users to log in to a web application through a magic link. This means that the user does not need to remember a password to log in, but simply clicks on a link that is sent to their email.

Index
-----

[](#index)

1. [Introduction](#introduction)
2. [Installation](#installation)
3. [Configuration](#configuration)
4. [Usage](#usage)
5. [API](#api)
6. [Advanced Customization](#advanced-customization)
7. [Error Handling](#error-handling)
8. [Contribute](#contribute)

Introduction
------------

[](#introduction)

UniLogin allows you to implement magic link login in your Laravel or Lumen application. This type of login is based on sending a link to the user's email that, when clicked, automatically logs in the user to your application.

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

[](#installation)

The installation of UniLogin is very simple. You can install it in a Laravel or Lumen application:

### Laravel

[](#laravel)

1. Run the following command:

    `composer require tecnomanu/unilogin`
2. Publish the configuration file and views:

    `php artisan vendor:publish --provider="Tecnomanu\UniLogin\LaravelServiceProvider"`

### Lumen

[](#lumen)

1. Run the following command:

    `composer require tecnomanu/unilogin`
2. Copy the configuration file and views:

    `php artisan unilogin:copy-views`

Configuration
-------------

[](#configuration)

Once the package is installed, you can configure it through the `config/unilogin.php` file or directly in your `.env` file.

- `UNILOGIN_SECRET`: Secret key to generate the magic links. You can generate it with the `php artisan unilogin:create-secret` command. Default: empty.
- `UNILOGIN_TOKEN_LIFETIME`: Lifetime of the magic link token in seconds. Default: 900 (15 minutes).
- `UNILOGIN_CALLBACK_URL`: URL where the application should redirect after a successful login. Default: empty.
- `UNILOGIN_API_BASE_PATH`: Base path for the API. Default: empty.

Configuración adicional para Lumen
----------------------------------

[](#configuración-adicional-para-lumen)

Si estás utilizando Lumen, necesitarás agregar algunas configuraciones adicionales para que este paquete funcione correctamente.

Añade las siguientes líneas en tu archivo `bootstrap/app.php`:

```
$app->alias('view', Illuminate\View\Factory::class);

$app->alias('mailer', \Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mail.manager', Illuminate\Mail\MailManager::class);
$app->alias('mail.manager', Illuminate\Contracts\Mail\Factory::class);
$app->alias('Notification', Illuminate\Support\Facades\Notification::class);

$app->configure('mail');
$app->configure('view');
```

Usage
-----

[](#usage)

1. Middleware

To use the UniLogin magic link, you need to use the middleware that comes with the package. You can add the middleware in your `web.php` or `api.php` routes file:

```
Route::get('/login-success', function (Request $request) {
    // Receive from request "email";

    // Your login logic here.
    // ...
    // Or use this example
    $user = User::where('email', $request->email)->first();
    Auth::login($user);
    return redirect('/');

})->middleware('unilogin.success');
```

API
---

[](#api)

UniLogin comes with several pre-configured routes that handle the different stages of the magic link login process. Here they are:

- `POST /unilogin`: Send the magic link to the user's email.
- `GET /unilogin/polling`: Check if the magic link has been clicked.
- `GET /unilogin/callback`: Handle the callback from the magic link.
- `GET /unilogin/error`: Show an error message if the login fails.
- `GET /unilogin/invalid-session`: Show a message if the session is invalid.
- `GET /unilogin/success`: Handle a successful login.

Advanced Customization
----------------------

[](#advanced-customization)

As you progress in the integration and use of the UniLogin package, you may find the need to make adjustments that better suit your project. In this section, we will explore some of the most common ways to customize UniLogin.

1. Middleware

    The UniLogin package comes with a custom middleware: `SuccessTokenMiddleware`. This middleware processes the SUCCESS type tokens and adds the user's email to the request. You might need to customize this middleware, for example, if you need to add more fields to the request.

    Here's an example of how you could customize this middleware to add a 'company\_id' field to the request:

    ```
    // SuccessTokenMiddleware.php  //...
    public function handle(Request $request, Closure $next) {
        // ...
        $credentials = $request->get('credentials');

        // Merge additional fields to the request

        $request->merge([
            'email' => $credentials['email'],
            'company_id' => $credentials['company_id']
        // New field
        ]);
        return $next($request);
    }
    //...
    ```
2. Views

    Views are another area where you might want to customize UniLogin. The error, invalid session and success views can be customized according to the needs of your project. You can copy the views into your application and make the necessary changes using the `unilogin:copy-views` command.

Error Handling
--------------

[](#error-handling)

Error handling is essential for providing a smooth and consistent user experience. The UniLogin package comes with a built-in error handling system, which throws different types of exceptions depending on the error occurred.

In most cases, the UniLogin package returns a JSON response with a description of the error and an HTTP status code. For example, if a token has expired, it will return a JSON response with the status 'error' and the corresponding message.

If you need a more custom error handling system, you could consider editing the functions that throw the exceptions in the middleware.

Contribute
----------

[](#contribute)

If you want to contribute to the development of UniLogin, you can follow these steps:

1. Fork the repository on GitHub.
2. Clone your fork to your local machine.
3. Create a new branch in your local repository.
4. Make your changes in the new branch.
5. Push the changes to your fork on GitHub.
6. Open a pull request from your fork to the main UniLogin repository.
7. After review and any necessary discussions, your changes may be merged into the main branch.

Before opening a pull request, please make sure to check the existing issues and pull requests to avoid duplication. Also, please follow the existing coding standards and conventions.

Thank you for your interest in contributing to UniLogin!

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1075d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2926fd0d4b509516aba9f8b5debbf45baf2357e08142efbe9b564798051e119d?d=identicon)[tecnomanu](/maintainers/tecnomanu)

---

Top Contributors

[![tecnomanu](https://avatars.githubusercontent.com/u/591261?v=4)](https://github.com/tecnomanu "tecnomanu (21 commits)")

---

Tags

jwtlaravelauthAuthenticationlumenJSON Web Tokenlogin providerlogin passport

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tecnomanu-unilogin-laravel-lumen/health.svg)

```
[![Health](https://phpackages.com/badges/tecnomanu-unilogin-laravel-lumen/health.svg)](https://phpackages.com/packages/tecnomanu-unilogin-laravel-lumen)
```

###  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)[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)[benbjurstrom/cognito-jwt-guard

A laravel auth guard for JSON Web Tokens issued by Amazon AWS Cognito

1113.1k](/packages/benbjurstrom-cognito-jwt-guard)

PHPackages © 2026

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