php - Laravel 5.3 using multiple authentication (e.g admin, customer) -


i have read lot of threads multi-auth in laravel, of configurations see somehow complicated, have seen multi-auth package not support laravel socialite.
aware question asked multiple times, if can give better answer. appreciated!

things have tried

  1. i familiar laravel make:auth

  2. i familiar laravel socialite facebook , twitter , google plus.

give try. still need basic knowledge laravel's new multitenancy.

  1. in config/auth.php add guards array:

    'customer' => [     'driver' => 'session',     'provider' => 'customers', ], 
  2. than in same file add providers array:

        'customers' => [         'driver' => 'eloquent',         'model' => app\customer::class,     ], 
  3. than create migration customers db table (you can use laravel's out of box migration users table)

  4. next eloquent model app\customer these included:

    use app\scopes\authorizedscope; use illuminate\foundation\auth\user authenticatable; 

these should let use laravel's auth facade in app these used methods:

    auth::guard('customer')->attempt()     auth::guard('customer')->check()     auth::guard('customer')->logout()     auth::guard('customer')->user() 

or use auth middleware this:

    route::get('customer/dashboard', function () {         // authenticated users may enter...     })->middleware('auth:customer'); 

also checkout these:

https://laravel.com/docs/5.3/authentication#authenticating-users


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -