30

GitHub - karlmonson/laravel-magic: Laravel Magic is a passwordless authenticatio...

 4 years ago
source link: https://github.com/karlmonson/laravel-magic
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Laravel Magic

Laravel Magic is a passwordless authentication driver. Users receive a login link via email.

Installation

Install via Composer:

composer require karlmonson/laravel-magic

The package service provider and facade will be automatically registered.

Setup

After installation, run migrations:

php artisan migrate

This will create a new table magic_auth_requests in your database.

Next, replace the default AuthenticatesUsers trait on your LoginController with the following:

use KarlMonson\Magic\Traits\AuthenticatesUsers;

class LoginController extends Controller
{
    use AuthenticatesUsers;

    ...
}

You'll also need to add the Magical trait to your user model:

use KarlMonson\Magic\Traits\Magical;

class User extends Authenticatable
{
    use Magical, Notifiable;

    ...
}

We suggest dropping the password column from your user table, or at least making it nullable.

Configuration

Next, in your auth config file, replace the 'users' driver with 'magic':

'providers' => [
    'users' => [
        'driver' => 'magic',
        'model' => App\User::class,
    ],
],

You may also specify an 'expire' option for Magic to use, this is how long login tokens will stay alive. The default is 10 if this is not specified.

'magic' => [
    'expire' => 10,
]

Credits

License

The MIT License (MIT). Please see License File for more information.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK