chuoke/laravel-user-identify

Laravel multi auth providers.

0.0.1 2021-10-07 11:12 UTC

This package is auto-updated.

Last update: 2024-04-07 17:20:20 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

NOT READY!!!!!!

Installation

You can install the package via composer:

composer require chuoke/laravel-user-identify

You can publish and run the migrations with:

php artisan vendor:publish --provider="Chuoke\UserIdentify\UserIdentifyServiceProvider" --tag="laravel-user-identify-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="Chuoke\UserIdentify\UserIdentifyServiceProvider" --tag="laravel-user-identify-config"

This is the contents of the published config file:

return [
];

Add user_identify guard provider to auth.php config file like this:

// config/auth.php
return [

    'defaults' => [
        'guard' => 'api',
        'passwords' => 'users',
    ],

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'jwt',
            'provider' => 'user_identify',
        ],
    ],

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\User::class,
        ],
        'user_identify' => [
            'driver' => 'user_identify',
            'model' => Chuoke\UserIdentify\Models\UserIdentify::class, // user identify model
        ],
    ],
    // ...
];

// AuthServiceProvider.php
Auth::provider($this->app['config']['identify']['auth_provider_name'] /* or 'user_identify' */, function ($app, array $config) {
    return new UserIdentifyProvider(
        $app['hash'],
        $config['model'],
        $app['config']['identify']['user_model']
    );
});

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

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