Skip to content

moonshine-software/two-factor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoonShine two-factor authentication

Requirements

  • MoonShine v3.0+

Support MoonShine versions

MoonShine Layouts
2.0+ 1.0+
3.0+ 2.0+

Installation

composer require moonshine/two-factor
php artisan migrate

Get started

Add pipe to config/moonshine.php

use MoonShine\TwoFactor\TwoFactorAuthPipe;

return [
    // ...
    'auth' => [
        // ...
        'pipelines' => [
            TwoFactorAuthPipe::class
        ],
        // ...
    ]
    // ...
];

or in MoonShineServiceProvider

use MoonShine\TwoFactor\TwoFactorAuthPipe;

$config->authPipelines([
    TwoFactorAuthPipe::class
]);

Add trait TwoFactorAuthenticatable to model or use MoonShine\TwoFactor\Models\MoonshineUser

use MoonShine\TwoFactor\Traits\TwoFactorAuthenticatable;

class MoonshineUser extends Model
{
    use TwoFactorAuthenticatable;
}

We will automatically add the component to the profile page, but if you use another page, you can add it yourself.

use MoonShine\TwoFactor\ComponentSets\TwoFactor;

protected function components(): iterable
{
    return [
        // ...

        TwoFactor::make(),
    ];
}