Skip to content

Instantly share code, notes, and snippets.

@mortenege
Created August 27, 2018 04:35
Show Gist options
  • Save mortenege/21a01fd2123727741124df22d148758f to your computer and use it in GitHub Desktop.
Save mortenege/21a01fd2123727741124df22d148758f to your computer and use it in GitHub Desktop.
How to set up a custom user provider in laravel

In the boot method of app\Providers\AuthServiceProvider.php

Auth::provider('wpdriver', function ($app, array $config) {
    return new WPUserProvider($app['hash'], $config['model']);
});

In config\auth.php modify providers with

'wpusers' => [
    'driver' => 'wpdriver',
    'model' => App\User::class,
],

and guards with

'wpguard' => [
    'driver' => 'session',
    'provider' => 'wpusers',
],

and then set default guard to wpguard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment