54ba
54ba

Reputation: 53

Two Custom authentication api laravel with JWT

In my Laravel project I've implemented users' authentication using JWT, socialite and dingo. Now I have other users which are in another table other than users table -let's call it 'doctors'- and i want to authenticate them. How to separate the sessions of the two tables even though the configuration for authentication is

//config/auth.php

'defaults' => [
    'guard' => 'api',
    'passwords' => 'users',
],
 'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

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

Upvotes: 1

Views: 523

Answers (1)

54ba
54ba

Reputation: 53

i have to edit config/auth to

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

    'user' => [
        'driver' => 'jwt',
        'provider' => 'users',
    ],
    'hospitalization' => [
        'driver' => 'jwt',
        'provider' => 'hospitalizations',
    ]
],

and use Auth::guard('hospitalization') when i need to separate

Upvotes: 2

Related Questions