I was created one project with laravel 5.4 and custom authentication to one table of Dynamics NAV (2017) trough web services, these are the steps that I was make to do this:

  • I was folow some steps As this article explains perfectly: CustomUserProvider.php 
      • Modify config/auth.php:
            'providers' => [
                'users' => [
                    //'driver' => 'eloquent',
                    'driver' => 'customuserprovider',
                    'model' => App\User::class,
                ],
        
                // 'users' => [
                //     'driver' => 'database',
                //     'table' => 'users',
                // ],
            ],
        
      • but then Modify providers/AuthServiceProvider to use my own customuserprovider:
         <?php namespace App\Providers; use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider { /** * The policy mappings for the application. * * @var array */ protected $policies = [ 'App\Model' => 'App\Policies\ModelPolicy',
            ];
        
            /**
             * Register any authentication / authorization services.
             *
             * @return void
             */
            public function boot()
            {
                $this->registerPolicies();
                // added to modify auth provider that's the trick
                 \Illuminate\Support\Facades\Auth::provider('customuserprovider', function($app, array $config) {
                return new CustomUserProvider($app['hash'], $config['model']);
                    });
                //
            }
        }
        
Facebooktwitterredditpinterestlinkedinmail