0

Authentication Defaults

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

Authentication Guards

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],        
    'api' => [
        'driver' => 'jwt',
        'provider' => 'users',
        'hash' => false,
    ],
    'student' => [
        'driver' => 'session',
        'provider' => 'students',
    ]

],

User Providers

 'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,      
    ],

    'students' => [
        'driver' => 'eloquent',
        'model' => App\Student::class,
    ]

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

when i try to login using student table username, password its not login but when i change the Auth Defaults to students

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

and api to students provider

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

its login using students table data but the users table datas not allow to login.

How can i implement this two users table to login??

thanks in advance

1 Answer 1

1

you should pass guard name to auth function :

auth('students')->login();

or

Auth::guard('students')->login()

or you override default guard by passing there to auth middleware:

Route::group(['middleware' => ['auth:students'] ], function(){
       //your routes here
    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.